Heap-102-fa10

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

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

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

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

View Full Document
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
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

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

View Full Document
Source: Muangsin / Weiss 4 Implementation using Binary Search Tree insert takes O(log N) time
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern