
















































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

















































Linked-list 2 5 8 10 15 ā
A max (min) heap is a complete binary tree such that the data stored in each node is greater (smaller) than the data stored in its children, if any.
Binary heap. Almost complete binary tree.
Properties. Min element is in root. Heap with N elements has height =  log 2 N . 06 14 (^78 ) 91 81 77 45 47 53 (^8384 )
Height = 3
Larger than its parent Not a heap
Missing left child Not a complete tree ā Not a heap
1 0001 6 0110 11 1011 2 0010 7 0111 12 1100 3 0011 8 1000 13 1101 4 0100 9 1001 14 1110 5 0101 10 1010 15 1111 After the first 1 from left: 0 ā left; 1 ā
for any node at index i parent = i/2 left child = i * 2 right child = i*2+
Insert element x into heap. Insert into next available slot. Bubble up until it's heap ordered.
Insert element x into heap. Insert into next available slot. Bubble up until it's heap ordered.
Insert element x into heap. Insert into next available slot. Bubble up until it's heap ordered.