priorityqueues 18

priorityqueues 18 - Priority Queues Definitions A priority...

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

View Full Document Right Arrow Icon
Priority Queues
Background image of page 1

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

View Full DocumentRight Arrow Icon
Priority Queues 2 Definitions A priority queue is a collection of zero or more elements, where each element has a priority or value. Operations defined for a priority queue: Create Destroy Size Empty Insert Retrieve Remove
Background image of page 2
Priority Queues 3 Ideas for Representation Scenario #1 Insert elements into pqueue in the same fashion as elements were inserted into a regular queue. Retrieve element with “highest” priority by performing a sequential search of queue. Scenario #2 Insert element in “appropriate” position in pqueue . This position depends on whether high priorities are represented with high or low values. Retrieve element in the same way that elements were retrieved from a regular queue. What is the performance of insertion and retrieval in these scenarios?
Background image of page 3

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

View Full DocumentRight Arrow Icon
Priority Queues 4 Can We Do Better? Of course…I wouldn’t ask if we couldn’t. Let’s consider a tree representation. Definitions
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 / 7

priorityqueues 18 - Priority Queues Definitions A priority...

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