



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
An overview of priority queues and heaps, important data structures in computer science. It discusses the motivation for using priority queues, the operations needed, and how they can be implemented using different data structures. The document then introduces binary heaps, a specialized data structure that can efficiently support key priority queue operations. It explains the properties of binary heaps, including the complete tree structure and heap order property, and describes how they can be implemented using an array. The document also includes sample code for basic heap operations. Overall, this provides a comprehensive introduction to priority queues and heaps, widely used in various applications.
Typology: Thesis
1 / 7
This page cannot be seen from the preview
Don't miss anything!
![]() | ![]() |
Insertion: Percolate Up
position pass def rightChild(self, position): # returns the position of the right child for the node currently at position pass bh = BinHeap() bh.buildHeap([ 2 , 4 , 6 , 7 , 5 ]) print(bh.parent( 4 )) 2 print(bh.delMin()) 2 print(bh.heapList[ 1 :bh.currentSize+ 1 ]) [4, 5, 6, 7] print(bh.delMin()) print(bh.delMin()) print(bh.delMin()) print(bh.delMin()) 4 5 6 7 bh1 = BinHeap() bh1.buildHeap([ 9 , 5 , 6 , 2 , 3 ]) print(bh1.heapList[ 1 :bh1.currentSize+ 1 ]) [2, 3, 6, 5, 9]