Page 519 - Cs_withBlue_J_C11_Flipbook
P. 519

42                  arr[k] = L[i];
                   43                  i++;

                   44                  k++;
                   45              }

                   46              /* Copy remaining elements of R[] if any */
                   47              while (j < n2)

                   48              {
                   49                  arr[k] = R[j];
                   50                  j++;

                   51                  k++;

                   52              }
                   53          }
                   54          //function to sort the array

                   55
                   56          void sort(int arr[], int l, int r)

                   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





                                                                                                                       517
                                                                                                   Internal Assessment  517
   514   515   516   517   518   519   520   521   522   523   524