xl-fiboheap - Algorithms Non-Lecture L Fibonacci Heaps A...

This preview shows pages 1–2. Sign up to view the full content.

Algorithms Non-Lecture L: Fibonacci Heaps A little and a little, collected together, become a great deal; the heap in the barn consists of single grains, and drop and drop makes an inundation. — Saadi (1184–1291) The trees that are slow to grow bear the best fruit. — Molière (1622–1673) Promote yourself but do not demote another. — Rabbi Israel Salanter (1810–1883) Fall is my favorite season in Los Angeles, watching the birds change color and fall from the trees. — David Letterman L Fibonacci Heaps L.1 Mergeable Heaps A mergeable heap is a data structure that stores a collection of keys 1 and supports the following operations. I NSERT : Insert a new key into a heap. This operation can also be used to create a new heap containing just one key. F IND M IN : Return the smallest key in a heap. D ELETE M IN : Remove the smallest key from a heap. M ERGE : Merge two heaps into one. The new heap contains all the keys that used to be in the old heaps, and the old heaps are (possibly) destroyed. If we never had to use D ELETE M IN , mergeable heaps would be completely trivial. Each “heap” just stores to maintain the single record (if any) with the smallest key. I NSERT s and M ERGE s require only one comparison to decide which record to keep, so they take constant time. F IND M IN obviously takes constant time as well. If we need D ELETE M IN , but we don’t care how long it takes, we can still implement mergeable heaps so that I NSERT s, M ERGE s, and F IND M IN s take constant time. We store the records in a circular doubly-linked list, and keep a pointer to the minimum key. Now deleting the minimum key takes Θ( n ) time, since we have to scan the linked list to ﬁnd the new smallest key. In this lecture, I’ll describe a data structure called a Fibonacci heap that supports I NSERT s, M ERGE s, and F IND M IN s in constant time, even in the worst case, and also handles D ELETE M IN in O ( log n ) amortized time. That means that any sequence of n I NSERT s, m M ERGE s, f F IND M IN s, and d D ELETE M IN s takes O ( n + m + f + d log n ) time. L.2 Binomial Trees and Fibonacci Heaps A Fibonacci heap is a circular doubly linked list, with a pointer to the minimum key, but the elements of the list are not single keys. Instead, we collect keys together into structures called binomial heaps . Binomial heaps are trees that satisfy the heap property —every node has a smaller key than its children—and have the following special recursive structure. A kth order binomial tree , which I’ll abbreviate B k , is deﬁned recursively. B 0 is a single node. For all k > 0, B k consists of two copies of B k - 1 that have been linked together, meaning that the root of one B k - 1 has become a new child of the other root. 1 In the earlier lecture on treaps, I called these keys priorities to distinguish them from search keys.

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Page1 / 8

xl-fiboheap - Algorithms Non-Lecture L Fibonacci Heaps A...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online