








Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Community
Ask the community for help and clear up your study doubts
Discover the best universities in your country according to Docsity users
Free resources
Download our free guides on studying techniques, anxiety management strategies, and thesis advice from Docsity tutors
A review of priority queues or heaps, focusing on their operations, running times, and implementation using an array or vector. It covers insertion and deletion processes, traversal, and the use of STL's priority_queue.
What you will learn
Typology: Schemes and Mind Maps
1 / 14
This page cannot be seen from the preview
Don't miss anything!
Priority Queues or Heaps (Review)
Insert 50, then 35, then 8 6 10 40 12 32 43 47 45 41
Delete min
**- Replace the root with the rightmost node at the last level
6 10 40
32 12 47 45 41 50 35 43
Insert into a heap
**- Insert key(x) in the first open slot at the last level of tree (going from left to right)
6 10 40 12 32 43 47 45 41
Value 6 10 12 40 32 43 47 45 41 Index 0 1 2 3 4 5 6 7 8 Traversing up the “tree”
Insert 8 into a heap Value 6 10 12 40 32 43 47 45 41 50 35 Index 0 1 2 3 4 5 6 7 8 9 10 After inserting 8, which node is the parent of 8? A. Node 6 B. Node 12 C. None 43 D. None - Node 8 will be the root
Delete min
**- Replace the root with the rightmost node at the last level
6 10 40
32 12 47 45 41 50 35 43
std::priority_queue (STL’s version of heap)
Next lecture
! 14