1 Replies - 4913 Views - Last Post: 23 April 2012 - 06:40 AM Rate Topic: -----

#1 thePhantom  Icon User is offline

  • D.I.C Head

Reputation: -1
  • View blog
  • Posts: 63
  • Joined: 28-April 10

Merging two Priority queues (arrayList and Linked List)

Posted 23 April 2012 - 03:22 AM

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?

Is This A Good Question/Topic? 0
  • +

Replies To: Merging two Priority queues (arrayList and Linked List)

#2 g00se  Icon User is online

  • D.I.C Lover
  • member icon

Reputation: 3390
  • View blog
  • Posts: 15,208
  • Joined: 20-September 08

Re: Merging two Priority queues (arrayList and Linked List)

Posted 23 April 2012 - 06:40 AM

Look at the docs http://docs.oracle.c...orityQueue.html
to begin with
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1