Answered You can hire a professional tutor to get the answer.

QUESTION

For the OrdArray class in the orderedArray.java program (Listing 2.

For the OrdArray class in the orderedArray.java program (Listing 2.4 on page 59), you are asked to add the following methods

·        A merge() method so you can merge two ordered source arrays into an ordered destination array. To simplify, for duplicate values (no mater in an array or two arrays), only count once.  

·        A common() method so you can get the common values owned by the two ordered source arrays into an ordered destination array. For duplicate values, only count once. 

·        Using the objected oriented analysis and design, using the available insert(), find(). delete() and display() methods.

·        You cannot use any available library. 

Write code in main() of class OrderedApp that inserts some random numbers into the two source arrays, invokes merge() and common() and displays the contents of the resulting arrays. The source arrays may hold different numbers of data items. In your algorithm you will need to compare the keys of the source arrays, picking the smallest one to copy to the destination. You'll also need to handle the situation when one source array exhausts its contents before the other.

Example:

Source array A = {3, 6, 8, 8, 11, 17, 25, 34, 38, 46, 48, 48, 48, 57, 62, 69, 72, 72, 77, 83};

Source array B = {5, 8, 14, 25, 31, 37, 41, 48, 48, 52, 77, 82, 94};

Then, Destination array C (after merge) = {3, 5, 6, 8, 11, 14, 17, 25, 31, 34, 37, 38, 41, 46, 48, 52, 57, 62, 69, 72, 77, 82, 83, 94};

Destination array D (after common) = {8, 25, 48, 77}; 

Show more
LEARN MORE EFFECTIVELY AND GET BETTER GRADES!
Ask a Question