This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: More Heaps Data Structures and Algorithms Andrei Bulatov Algorithms – More Heaps 222 Binomial Heap: Union Create heap H that is union of heaps H‘ and H''. – "Mergeable heaps." – Easy if H‘ and H'' are each order k binomial trees. • connect roots of H‘ and H'' oose smaller key to be root of H • choose smaller key to be root of H H'' 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 H' Algorithms – More Heaps 223 Binomial Heap: Union 30 23 22 48 31 17 44 8 29 10 6 37 3 18 15 7 12 + 1 1 1 1 1 1 1 1 1 1 1 1 19 + 7 = 26 55 45 32 24 50 41 33 28 25 + Algorithms – More Heaps 224 Binomial Heap: Union 30 23 22 48 31 17 44 8 29 10 6 37 3 18 15 7 12 55 45 32 24 50 41 33 28 25 + Algorithms – More Heaps 225 Binomial Heap: Union 30 23 22 48 31 17 44 8 29 10 6 37 3 18 15 7 12 12 18 55 45 32 24 50 41 33 28 25 + 30 23 22 48 31 17 44 8 29 10 6 37 3 15 7 12 18 25 37 7 3 18 12 Algorithms – More Heaps 226 6 55 45 32 24 50 41 33 28 25 + 18 12 30 23 22 48 31 17 44 8 29 10 6 37 3 15 7 12 18 25 37 7 3 41 28 33 25 37 15 7 3 18 12 Algorithms – More Heaps 227 7 55 45 32 24 50 41 33 28 25 + 18 12 30 23 22 48 31 17 44 8 29 10 6 37 3 15 7 12 18 25 37 7 3 41 28 33 25 37 15 7 3 18 12 Algorithms – More Heaps 228 8 55 45 32 24 50 41 33 28 25 + 18 12 41 28 33 25 37 15 7 3 30 23 22 48 31 17 44 8 29 10 6 37 3 15 7 12 18 25 37 7 3 41 28 33 25 37 15 7 3 18 12 Algorithms – More Heaps 229 9 55 45 32 24 50 41 33 28 25 + 18 12 41 28 33 25 37 15 7 3 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 6 Algorithms – More Heaps 2210 Union: Running Time Proof he running time is proportional to the number of trees in root lists, Theorem [ Union can be executed in O(log n) time The running time is proportional to the number of trees in root lists, which is at most 2( log N + 1). QED Algorithms – More Heaps 2211 Delete Minimal Delete node with minimum key in binomial heap H. – Find root x with min key in root list of H, and delete – H' := broken binomial trees – H := Union(H', H) Running time: O(log N) 3 37 6 18 55 45 32 30 24 23 22 50 48 31 17 44 8 29 10 H Algorithms – More Heaps 2212 Delete Minimal Delete node with minimum key in binomial heap H. – Find root x with min key in root list of H, and delete – H' := broken binomial trees – H := Union(H', H) Running time: O(log N) 55 45 32 30 24 23 22 50 48 31 17 37 6 18 44 8 29 10 H H' Algorithms – More Heaps 2213 Decrease Key Decrease key of node x in binomial heap H. – Suppose x is in binomial tree B k . – Bubble node x up the tree if x is too small. Running time: O(log N) roportional to depth of node x g – Proportional to depth of node x ≤ log 2 N . 3 37 6 18 55 x 32 30 24 23 22 50 48 31 17 44 8 29 10 H depth = 3 Algorithms – More Heaps 2214 Delete Delete node x in binomial heap H....
View
Full Document
 Fall '09
 A.BULATOV
 Algorithms, Data Structures, Analysis of algorithms, Prime number, Fibonacci heap, binomial heap, fibonacci heaps

Click to edit the document details