Question: 4) Write a program to sort two random arrays keyed in by the user into descending order, and merge them into a new array containing

 4) Write a program to sort two random arrays keyed in

4) Write a program to sort two random arrays keyed in by the user into descending order, and merge them into a new array containing all the elements in the two arrays in descending order. Print the input arrays and the merged array. You may assume the elements in the two arrays are all different. Test your program with input $\mathrm{A}=\{3,1,5,4,2\}$ and $\mathrm{B}=\{8,4,2,6,10\} .$ Your program should output $\ {10,9,8,7,6,5,4,$, $3,2,1\}$. (Hint: use two variables to mark the index of the current largest element in each array while scanning through the arrays) CS.VS. 1018

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 Databases Questions!