So my assignment required that we create an arrayList priority queue of an unsorted array (data was taken from a text file) and print out the first 50 values, in order of priority. Then we had to do this using a linked list also. The part that I'm confused about, is how to go about merging the two Priority Queues, to form a single heap, and creating a new one that is the combination of the two.
According to my knowledge, I know that you could actually create two binary heaps to store the elements from the unsorted arrayList and the linked list. Creating an array that is a concatenation of the first heap's array and the second's heaps array... Getting an array-backed binary tree. Then to iteratively heap sort all sub-heaps progressively from the leaves nodes to the root node.
My problem is, that I'm having trouble putting this method into code, and was wondering if someone could perhaps guide me on an easier way to do this, or recommend any tutorials I can go through?
1 Replies - 4070 Views - Last Post: 23 April 2012 - 06:40 AM
Replies To: Merging two Priority queues (arrayList and Linked List)
Page 1 of 1