Heap-102-fa10 - Priority Queue (Heap) A kind of queue...

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

View Full Document Right Arrow Icon
Source: Muangsin / Weiss 1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value (key) of each object (smaller value higher priority, or higher value hig her priority) Example Applications: printer -> print (dequeue) the shortest document first operating system -> run (dequeue) the shortest job first normal queue -> dequeue the first enqueued element first
Background image of page 1

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

View Full DocumentRight Arrow Icon
Source: Muangsin / Weiss 2 Priority Queue (Heap) Operations insert (enqueue) deleteMin (dequeue) smaller value higher priority Find / save the minimum element, delete it from structure and return it Priority Queue insert deleteMin
Background image of page 2
Source: Muangsin / Weiss 3 Implementation using Linked List Unsorted linked list insert takes O(1) time deleteMin takes O(N) time Sorted linked list insert takes O(N) time deleteMin takes O(1) time
Background image of page 3

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

View Full DocumentRight Arrow Icon
Source: Muangsin / Weiss 4 Implementation using Binary Search Tree insert takes O(log N) time
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 15

Heap-102-fa10 - Priority Queue (Heap) A kind of queue...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online