Design and Analysis of Algorithms
Design and Analysis of Algorithms
Algorithms
Instructor: Miss.Roaa Solh
By:Khaled Dahrouj
Mahmoud Dafer
Moe Mehyedine
COSC 216
Priority Queues:
Definition: a priority queue is an abstract data type which is like a
regular queue or stack data structure, but where additionally each element
has a "priority" associated with it. In a priority queue, an element with
high priority is served before an element with low priority.
Code example:
/ \ / \
20 100 15 30
/ / \ / \
30 40 50 100 40
Array Implementation:
Very efficient
No inner class of nodes needed – no links needed for children
Use index and child index computations
20 75 43 84 90 57 71 93 …
Disadvantage: May be slower than optimal and may use lots of space
to store all N records for huge N.