Question: write a program to merge two arrays For example, consider two arrays A and B. And then sort the arrays. Lets say I have A

write a program to merge two arrays

For example, consider two arrays A and B. And then sort the arrays.

Lets say I have

A = {10, 25, 35, 40, 55}

B = {15, 30, 5, 20, 45, 65}

After sorting

A = {10,25,35,40,55}

B={ 5,15,20,30,45,65}

The merged array should be another array C with elements {5, 10, 15, 20, 25, 30, 35, 40, 45, 55, 65}.

The resultant merged array should contain all the elements of A and B in sorted order. This doesn't mean that you can two copy two arrays to the third array and sort the resultant array. However, you have to merge the contents of the two arrays by taking individual values of the two arrays one by one and insert it into the resultant array in the appropriate position, so that it becomes sorted right after merging.

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!