Question
Add a merge() method to the OrdArray class discussed in Section 2.3 (See below) of the lecture notes. The merge() method should accept two ordered
Add a merge() method to the OrdArray class discussed in Section 2.3 (See below) of the lecture notes. The merge() method should accept two ordered source arrays as parameters and merge them into an ordered destination array. Add appropriate code in main() of the OrderedApp class that inserts some numbers into the two source arrays, invokes merge(), and displays the contents of the two source arrays and the resulting destination array. Note: The source arrays may be of different sizes. In your algorithm you will need to compare the keys of the source arrays, picking the smallest one to copy into the destination array. Thus, you will need to handle the situation when one source array exhausts its contents before the other.
Note: You cannot use the insert method in your merge method.
Sample I/O:
Array A-0 11 22 33 44 55 66 77 88 99 Array B - 13 23 43 63 After merging, Array C-0 11 13 22 23 33 43 44 55 63 66 77 88 99Step 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