Presentation is loading. Please wait.

Presentation is loading. Please wait.

A simpler implementation and analysis of Chazelle’s

Similar presentations


Presentation on theme: "A simpler implementation and analysis of Chazelle’s"— Presentation transcript:

1 A simpler implementation and analysis of Chazelle’s
SOFT HEAPS Haim Kaplan – Tel Aviv University Robert E. Tarjan – Princeton Univ. & HP Uri Zwick – Tel Aviv University TexPoint fonts used in EMF. Read the TexPoint manual before you delete this box.: AAAA

2 Heaps vs. Soft Heaps All bounds are amortized
Fibonacci heaps Chazelle’s Soft Heaps Our Soft Heaps Make-heap O(1) Insert O(log 1/) Delete-min O(log n) Meld All bounds are amortized Soft heaps may increase keys of items Items with increased keys are corrupted At most  n items in the heaps are corrupted, where n is the total number of insertions

3 Applications of Soft Heaps
A deterministic O(m(m,n))-time algorithm for finding minimum spanning trees [Chazelle ’00] An optimal deterministic algorithm for finding minimum spanning trees (with a yet unknown running time) [Pettie-Ramachandran ’02] New selection and approximate sorting algorithms [Chazelle ’00]

4 (Approximate) Selection with soft heaps
Finding an approximate median: Insert the n elements into a soft heap (=1/4) Perform (1- )n/2 delete-min operations Find the maximum x of the elements extracted /* Rank of x is between (1)n/2 and (1+)n/2 */ Selecting the k-th largest element Find an approximate median x Find the rank of x Continue with elements smaller/larger than x

5 Analogous to Chazelle’s representation of binomial trees
Half-empty trees Each non-leaf node has a non-empty child and an empty child. (Usually …) 22 20 30 35 Analogous to Chazelle’s representation of binomial trees

6 Half-empty trees with lists
Corrupted key of all items in the list Original keys Tree is “heap ordered” with respect to corrupted keys 10 18 1 12 2 4 16 17 18 Each node has a rank 9 9 22 22 15 3 8 7 8 8 35 35 30 30 Each node has a list of items. (Most) items in lists of length>1 are corrupted

7 (Fighting) Corruption
The target size of a non-empty node of rank k is sk Corrupted items rank > r Claim: A node of rank k>r contains at most 4sk elements rank ≤ r Claim: Number of nodes of rank k is at most n/2k Non-corrupted items

8 Soft heaps A soft heap is a list of half-empty trees.
Trees in the list have increasing rank. Each root has a suffix-min pointer to the root with the smallest corrupted key following it. 2 7 10 58 3 20 58 3 4 14 19 5 18 1 12 2 4 16 17 18 As in Chazelle’s implementation Potential = largest rank + # trees

9 Sifting Sift at the empty child
Fill a node x of rank k with at least sk elements, or fill it with all the elements in its subtree and make it a leaf. 18 1 12 2 4 16 17 18 Sift at the empty child 20 4 14 19 5

10 Move items from smaller child
Sifting Fill a node x of rank k with at least sk elements, or fill it with all the elements in its subtree and make it a leaf. 18 1 12 2 4 16 17 18 Move items from smaller child 20 56 4 14 20 5 44 10 45 56

11 Repeat if more elements needed
Sifting Fill a node x of rank k with at least sk elements, or fill it with all the elements in its subtree and make it a leaf. Repeat if more elements needed 20 1 12 2 4 16 17 18 4 14 20 5 56 44 10 45 56

12 Sifting – delete empty leaves
18 20 56 1 12 2 4 16 17 14 5 44 10 45 20 1 12 2 4 16 17 18 4 14 20 5 56 44 10 45 56 Delete empty leaves

13 Shortcut empty nodes with a single child
Sifting – shortcuts Shortcut empty nodes with a single child 18 1 12 2 4 16 17 18 20 1 12 2 4 16 17 18 4 14 20 5 20 4 14 20 5 56 44 10 45 56 56 44 10 45 56

14 Combining k+1 k k Move items from smaller child
Combine two trees of rank k into one tree of rank k+1 k+1 k k Move items from smaller child 20 56 4 14 20 5 44 10 45 56

15 Combine two trees of rank k into one tree of rank k+1
Combining Combine two trees of rank k into one tree of rank k+1 k+1 Sift 20 4 14 20 5 k k 56 44 10 45 56

16 Melding Combine trees of equal rank Re-compute suffix-min pointers
58 4 14 20 5 7 2 1 12 16 17 18 k1 3 29 1 9 12 13 7 k2 2 17 Combine trees of equal rank Re-compute suffix-min pointers Actual cost (excluding sift operations) = O(min{k1,k2}+1) Amortized cost (excluding sift operations) = O(1)

17 Delete-min Follow the suffix-min pointer of the first tree
Remove and return an item from the list of its root 2 k 1053 58 15 10 18 58 15 10 4 9 3 1 12 2 4 16 17 18 If list is empty, sift If still empty, delete root Update suffix-min pointers Actual cost (excluding sift operations) = O(k+1)

18 Analysis of Delete-min
Potential of root – number of items deleted since last sift If a root is empty, but its subtree is not empty, then its potential is at least sk ≥ kr 58 18 15 10 k 2 1053 Amortized cost = O(r) Total cost of removing roots of empty trees: Actual cost = O(k+1)

19 Total cost of sifting/moving
What is the total number of moves? Full moves – at least sk elements moved k All moves Non-full moves Full moves Full moves with k≥r Full moves with k<r Split the cost among the items moved! Total cost: Only the first and last move out of each node may be non-full

20 Open problems More applications of soft heaps? Worst-case bound?
Decrease-key operations? More applications of soft heaps?

21 THE END


Download ppt "A simpler implementation and analysis of Chazelle’s"

Similar presentations


Ads by Google