Merging Sorted Array: Java Framework


package mergesortedarrays;
public class MergeSortedArrays {

  public static void main(String[] args) {
    MergeSortedArrays m = new MergeSortedArrays();
    
    // Define the two sorted arrays to be merged
    int[] first = {0, 3, 6, 8, 12, 15};
    int[] second = {1, 3, 4, 10, 11, 17};
    
    // Make the call to the merge method (which you have to write)
    int[] merged = m.merge(first, second);
    
    // Print out the merged array so you can see if it worked
    System.out.print("{");
    for(int i = 0; i < merged.length - 1; i++) {
      System.out.print(merged[i] + ", ");
    }
    System.out.println(merged[merged.length] + "}");
  }
  
  int[] merge(int[] a, int[] b) {
    // add your code here
  }
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s