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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started