Page 590 - ComputerScience_Class_11
P. 590
57 {
58 if (l < r)
59 {
60 // Find the middle point
61 int m = (l+r)/2;
62
63 // Sort first and second halves
64 sort(arr, l, m);
65 sort(arr , m+1, r);
66
67 // Merge the sorted halves
68 merge(arr, l, m, r);
69 }
70 }
71
72 public static int[] add(int a[], int b[],int size)
73 {
74 int ar3[]=new int[size];//for storing the sum of the 2 arrays
75 //findind the sum
76 for(int i=0;i<size;i++)
77 {
78 ar3[i]=a[i]+b[i];
79 }
80
81 System.out.println("the sum of the 2 arrays is:");
82 printArray(ar3);
83 return ar3;
84 }
85 //function for printing the array
86
87 public static void printArray(int arr[])
88 {
588 Touchpad Computer Science (Ver. 3.0)-XI

