



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!




R l r ll lr rl rr root
R l
Priority Queue Note: STL provides deleteMax. But book provides deleteMin. We’ll follow the deleteMax strategy. deleteMax
int main() { priority_queue
Void push(t) void pop() T& top() void clear() bool empty()
The Push Heap Algorithm
R l r ll lr rl rr
The Push Heap Algorithm
R l r ll lr rl rr
The Push Heap Algorithm
swap
stop 7 6 5 4 3 8 R l r ll lr rl rr
The Push Heap Algorithm
swap
stop 7 6 5 4 3 8 R l r ll lr rl rr
The Push Heap Algorithm
swap
stop 7 6 8 4 3 5 R l r ll lr rl rr
The Push Heap Algorithm
swap
stop 7 6 8 4 3 5 R l r ll lr rl rr
The Push Heap Algorithm
swap
stop 7 6 8 4 3 5 R l r ll lr rl rr
The Push Heap Algorithm
swap
stop 8 6 7 4 3 5 R l r ll lr rl rr
The Pop-Heap Algorithm
swap
stop
The Pop Heap Algorithm
R l r ll lr rl rr
The Pop Heap Algorithm
R l r ll lr rl rr
The Pop Heap Algorithm
R l r ll lr rl rr