Fibonacci Heaps
Total Page:16
File Type:pdf, Size:1020Kb
Fibonacci Heaps Outline for Today ● Recap from Last Time ● Quick refresher on binomial heaps and lazy binomial heaps. ● The Need for decrease-key ● An important operation in many graph algorithms. ● Fibonacci Heaps ● A data structure efficiently supporting decrease- key. ● Representational Issues ● Some of the challenges in Fibonacci heaps. Recap from Last Time (Lazy) Binomial Heaps ● Last time, we covered the binomial heap and a variant called the lazy binomial heap. ● These are priority queue structures designed to support efficient melding. ● Elements are stored in a collection of binomial trees. 2 1 2 0 7 4 5 5 1 3 8 7 6 9 8 Eager Binomial Heap Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 2 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 2 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 3 2 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 3 2 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 3 2 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 3 2 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 2 3 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 3 2 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 3 2 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 3 2 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 3 2 6 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 3 2 6 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 3 2 6 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 7 3 2 6 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 7 3 2 6 8 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 7 3 2 6 8 4 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 3 2 6 4 7 8 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 3 2 7 6 4 8 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 3 2 7 6 4 8 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 2 3 7 6 4 8 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 5 2 3 7 6 4 8 Lazy Binomial Heap Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 9 5 2 3 7 6 4 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens if we enqueue the numbers 1, 2, 3, 4, 5, 6, 7, 8, and 9 into each heap. Eager Binomial Heap 1 9 5 2 3 7 6 4 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 1 9 5 2 3 7 6 4 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 9 5 2 3 7 6 4 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 9 5 2 3 7 6 4 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 3 9 7 6 4 2 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 3 9 7 6 4 2 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 3 9 7 6 4 2 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 3 2 7 6 4 9 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 3 7 6 4 8 2 9 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 3 7 6 4 8 2 9 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 2 7 6 3 9 8 4 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 5 2 7 6 3 9 8 4 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap 1 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap Order 2 Order 1 Order 0 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap Order 2 Order 1 Order 0 2 3 4 5 6 7 8 9 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap Order 2 Order 1 Order 0 2 3 5 6 7 8 9 4 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap Order 2 Order 1 Order 0 3 2 5 6 7 8 9 4 Draw what happens after performing an extract-min in each binomial heap. Eager Binomial Heap 2 5 9 3 7 6 4 8 Lazy Binomial Heap Order 2 Order 1 Order 0 3 2 5 6 7 8 9 4 Draw what happens after performing an extract-min in each binomial heap.