{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Priority Queues and Heaps_Part_7

Priority Queues and Heaps_Part_7 - Iterative vs Recursive...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 31 - Iterative vs Recursive MakeHeap Recursive and Iterative MakeHeap do essentially the same thing: Heapify from bottom to top. Difference: Recursive is “depth-first” Iterative is “breadth-first”
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 32 - Adaptable Priority Queues 3 a 5 g 4 e
Background image of page 2
Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 33 - Recall the Entry and Priority Queue ADTs An entry stores a (key, value) pair within a data structure Methods of the entry ADT: key (): returns the key associated with this entry value (): returns the value paired with the key associated with this entry Priority Queue ADT: insert (k, x) inserts an entry with key k and value x removeMin () removes and returns the entry with smallest key min () returns, but does not remove, an entry with smallest key size (), isEmpty ()
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Last Updated: 06/02/12 8:32 PM CSE 2011 Prof. J. Elder - 34 - Motivating Example Suppose we have an online trading system where orders to
Background image of page 4
Background image of page 5
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}