L18_PriorityQueue

L18_PriorityQueue - What are Priority Queues We introduce a...

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

What are Priority Queues We introduce a new Data Structure called priority queues . A Queue: Page 1 of 44

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

View Full Document
A Priority Queue E N N Q U U E E U U E E Page 2 of 44
What are Priority Queues In computer science, we use priority queues to store val- ues. 10 8 7 4 3 3 4 7 10 10 8 p r i o r i t y e n q u e u e 7 4 3 P r i o r i t y q u e u e o f i n t e g e r s 23 15 6 4 2 4 6 23 15 2 4 p r i o r i t y d e q u e u e 23 15 6 P r i o r i t y q u e u e o f i n t e g e r s Page 3 of 44

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

View Full Document
What are Priority Queues Of course, we also have priority queues of floats, priority queues of shapes, etc. , but we are not going to show them here. P r i o r i t y q u e u e o f f l o a t s P r i o r i t y q u e u e o f s h a p e s P r i o r i t y q u e u e o f Page 4 of 44
Priority Queue Operations The priority-enqueue operation inserts a new element at an ‘appropriate ’ position of a priority queue, according to the element’s priority . p r i o r i t y - e n q u e u e Page 5 of 44

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

View Full Document
Priority Queue Operations The priority-dequeue operation deletes and returns one element in a priority queue, which is always the element with the ‘smallest’ priority. Page 6 o p r i o r i t y - d e q u e u e This element with the ‘smallest’ prior- ity is returned by priority-dequeue .
BIG DISCOVERY !!! A priority queue is NOT a queue. It is NOT a First-In-First-Out (FIFO) structure. Page 7 of 44 3 p r i o r i t y - e n q u e u e 8 p r i o r i t y - e n q u e u e 10 7 4 3 10 7 4 10 7 4 4 7 10 4 p r i o r i t y - d e q u e u e 8 8 8 3 p r i o r i t y - d e q u e u e 10 7 4 3 10 7

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

View Full Document
BIG DISCOVERY !!!
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