Question: Write a JAVA program to read in a set of numbers and perform a MergeSort to arrange the numbers in ascending order. Your program is

Write a JAVA program to read in a set of numbers and perform a "MergeSort" to arrange the numbers in ascending order. Your program is expected to use Queues to keep track of the ascending "runs" in the numbers, which are portions that are already in order. Down below is some of the code.

public class NumberQueue { public static final int MAXSIZE=100; public int getQsize() { return (MAXSIZE+lastLoc-firstLoc) % MAXSIZE; } public boolean fullCheck() { return (getQsize() == MAXSIZE-1); } public boolean emptyCheck() { return (getQsize() == 0); } public int insert(int val) { if (fullCheck()) return -1; else { numArray[lastLoc] = val; lastLoc = (lastLoc +1) % MAXSIZE; return 0; } } public int front() { return numArray[firstLoc]; } public void remove() { if (!emptyCheck()) firstLoc = (firstLoc +1) % MAXSIZE; } private int firstLoc=0; private int lastLoc=0; private int[] numArray = new int[MAXSIZE]; }

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!