Question: Write a method union ( int [ ] a , int [ ] b ) that returns an array that is the union of the

Write a method union(int[] a, int[] b) that returns an array that is the union of the elements in the two arrays. You may assume that the input arrays a and b are always given as sorted arrays (increasing order). The union of the elements is all of the elements from both arrays without any duplicates. The resulting array should also be in sorted order. Examples: Input: a ={1,1,2,2,2,4}, b ={2,2,4,4} Output: {1,2,4} Input: a ={3,5,10,10,10,15,15,20}, b ={5,10,10,15,30} Output: {3,5,10,15,20,30}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!