A simpler implementation and analysis of Chazelle’s

Slides:



Advertisements
Similar presentations
Fibonacci Heaps Especially desirable when the number of calls to Extract-Min & Delete is small (note that all other operations run in O(1) This arises.
Advertisements

Priority Queues  MakeQueuecreate new empty queue  Insert(Q,k,p)insert key k with priority p  Delete(Q,k)delete key k (given a pointer)  DeleteMin(Q)delete.
Advanced Data structure
Rank-Pairing Heaps Robert Tarjan, Princeton University & HP Labs Joint work with Bernhard Haeupler and Siddhartha Sen, ESA
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA
Binomial Heaps. Min Binomial Heap Collection of min trees
Instructors: C. Y. Tang and J. S. Roger Jang All the material are integrated from the textbook "Fundamentals of Data Structures in C" and some supplement.
Fibonacci Heaps. Single Source All Destinations Shortest Paths
Chapter 10 Search Structures Instructors: C. Y. Tang and J. S. Roger Jang All the material are integrated from the textbook "Fundamentals of Data Structures.
Heaps and heapsort COMP171 Fall 2005 Part 2. Sorting III / Slide 2 Heap: array implementation Is it a good idea to store arbitrary.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
Heapsort CIS 606 Spring Overview Heapsort – O(n lg n) worst case—like merge sort. – Sorts in place—like insertion sort. – Combines the best of both.
ANALYSIS OF SOFT HEAP Varun Mishra April 16,2009.
1 Binomial heaps, Fibonacci heaps, and applications.
B-Tree. B-Trees a specialized multi-way tree designed especially for use on disk In a B-tree each node may contain a large number of keys. The number.
Chapter 9 Heap Structures
The Power of Incorrectness A Brief Introduction to Soft Heaps.
Data Structure & Algorithm II.  Delete-min  Building a heap in O(n) time  Heap Sort.
Sorting. Pseudocode of Insertion Sort Insertion Sort To sort array A[0..n-1], sort A[0..n-2] recursively and then insert A[n-1] in its proper place among.
Union Find ADT Data type for disjoint sets: makeSet(x): Given an element x create a singleton set that contains only this element. Return a locator/handle.
Binomial Tree B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4 Adapted from: Kevin Wayne B k : a binomial tree B k-1 with the addition of a left child with another.
Data StructuresData Structures Priority Queue. Recall Queues FIFO:First-In, First-Out Some contexts where this seems right? Some contexts where some things.
Priority Queues and Heaps Data Structures and Algorithms CS 244 Brent M. Dingle, Ph.D. Department of Mathematics, Statistics, and Computer Science University.
Fibonacci Heaps. Analysis FibonacciAnalysis.ppt Video  iew/cop5536sahni
1 Fibonacci heaps: idea List of multiway trees which are all heap-ordered. Definition: A tree is called heap-ordered if the key of each node is greater.
2 Binary Heaps What if we’re mostly concerned with finding the most relevant data?  A binary heap is a binary tree (2 or fewer subtrees for each node)
Fibonacci Heap Fibonacci heapshave better asymptotic time bounds than binary heaps for the INSERT, UNION, and DECREASE-KEY operations, and they.
School of Computing Clemson University Fall, 2012
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Heaps, Heap Sort and Priority Queues
Binomial heaps, Fibonacci heaps, and applications
Priority Queues © 2010 Goodrich, Tamassia Priority Queues 1
Heaps 8/2/2018 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser,
Binomial Heaps On the surface it looks like Binomial Heaps are great if you have no remove mins. But, in this case you need only keep track of the current.
Heaps Binomial Heaps Lazy Binomial Heaps 1.
Source: Muangsin / Weiss
Heaps 9/13/2018 3:17 PM Heaps Heaps.
Heap Sort Example Qamar Abbas.
Binomial Tree Adapted from: Kevin Wayne Bk-1 B0 Bk
Priority Queues MakeQueue create new empty queue
Fibonacci Heaps Remove arbitrary is useful in (for example) correspondence structures and may also be used to do an increase key in a min structure (remove.
Data Structures Lecture 4 AVL and WAVL Trees Haim Kaplan and Uri Zwick
Haim Kaplan and Uri Zwick November 2014
Pairing Heaps Actual Complexity.
Selection in heaps and row-sorted matrices
Lecture 26 Multiway Search Trees Chapter 11 of textbook
Part-D1 Priority Queues
Ch 6: Heapsort Ming-Te Chi
Tree Representation Heap.
© 2013 Goodrich, Tamassia, Goldwasser
ערמות בינומיות ופיבונצ'י
B-Tree.
§3 Worst-Case vs. Amortized
Strict Fibonacci Heaps
Fibonacci Heaps Remove arbitrary is useful in (for example) correspondence structures.
Heaps © 2014 Goodrich, Tamassia, Goldwasser Heaps Heaps
Binary and Binomial Heaps
Binomial heaps, Fibonacci heaps, and applications
HEAPS.
Algorithms: Design and Analysis
Union-Find with Constant Time Deletions
Red Black Trees (Guibas Sedgewick 78)
2-3 Trees Extended tree. Tree in which all empty subtrees are replaced by new nodes that are called external nodes. Original nodes are called internal.
Binomial heaps, Fibonacci heaps, and applications
Priority Queues Supports the following operations. Insert element x.
Chapter 12 Heap ADT © 2011 Pearson Addison-Wesley. All rights reserved.
Pairing Heaps Actual Complexity
Heaps & Multi-way Search Trees
Heaps 9/29/2019 5:43 PM Heaps Heaps.
Presentation transcript:

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

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

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]

(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

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

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

(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

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

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

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

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

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

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

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

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

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)

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)

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)

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

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

THE END