Four different data structures, each one best in a different setting. Simple Heap Balanced Heap Fibonacci Heap Incremental Heap Our results.

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

COL 106 Shweta Agrawal and Amit Kumar
Heaps1 Part-D2 Heaps Heaps2 Recall Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is a pair (key, value)
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.
Chapter 4: Trees Part II - AVL Tree
Augmenting Data Structures Advanced Algorithms & Data Structures Lecture Theme 07 – Part I Prof. Dr. Th. Ottmann Summer Semester 2006.
Advanced Data structure
Rank-Pairing Heaps Robert Tarjan, Princeton University & HP Labs Joint work with Bernhard Haeupler and Siddhartha Sen, ESA
1 Finger search trees. 2 Goal Keep sorted lists subject to the following operations: find(x,L) insert(x,L) delete(x,L) catenate(L1,L2) : Assumes that.
Binary Trees, Binary Search Trees CMPS 2133 Spring 2008.
F00 pq 1 Priority Queues Review the abstract data type Priority Queues Review different implementation options.
CSE332: Data Abstractions Lecture 7: AVL Trees Tyler Robison Summer
Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA
Nick Harvey & Kevin Zatloukal
Trees and Red-Black Trees Gordon College Prof. Brinton.
Source: Muangsin / Weiss1 Priority Queue (Heap) A kind of queue Dequeue gets element with the highest priority Priority is based on a comparable value.
1 Red Black Trees (Guibas Sedgewick 78). 2 Goal Keep sorted lists subject to the following operations: find(x,L) insert(x,L) delete(x,L) catenate(L1,L2)
Balanced Trees. Binary Search tree with a balance condition Why? For every node in the tree, the height of its left and right subtrees must differ by.
5.9 Heaps of optimal complexity
Binary search trees Definition Binary search trees and dynamic set operations Balanced binary search trees –Tree rotations –Red-black trees Move to front.
Binomial Heaps Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Fibonacci Heaps These lecture slides are adapted from CLRS, Chapter 20.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 11 Tuesday, 12/4/01 Advanced Data Structures Chapters.
1 BST Trees A binary search tree is a binary tree in which every node satisfies the following: the key of every node in the left subtree is.
1 Binomial heaps, Fibonacci heaps, and applications.
Compiled by: Dr. Mohammad Alhawarat BST, Priority Queue, Heaps - Heapsort CHAPTER 07.
PRIORITY QUEUES (HEAPS). Queues are a standard mechanism for ordering tasks on a first-come, first-served basis However, some tasks may be more important.
New Balanced Search Trees Siddhartha Sen Princeton University Joint work with Bernhard Haeupler and Robert E. Tarjan.
Binomial heaps, Fibonacci heaps, and applications
The Binary Heap. Binary Heap Looks similar to a binary search tree BUT all the values stored in the subtree rooted at a node are greater than or equal.
Data Structure & Algorithm II.  Delete-min  Building a heap in O(n) time  Heap Sort.
Binary Trees, Binary Search Trees RIZWAN REHMAN CENTRE FOR COMPUTER STUDIES DIBRUGARH UNIVERSITY.
Data Structures Week 8 Further Data Structures The story so far  Saw some fundamental operations as well as advanced operations on arrays, stacks, and.
1 Trees 4: AVL Trees Section 4.4. Motivation When building a binary search tree, what type of trees would we like? Example: 3, 5, 8, 20, 18, 13, 22 2.
Comp 335 File Structures B - Trees. Introduction Simple indexes provided a way to directly access a record in an entry sequenced file thereby decreasing.
1 Searching Searching in a sorted linked list takes linear time in the worst and average case. Searching in a sorted array takes logarithmic time in the.
Analysis of Algorithms CS 477/677 Instructor: Monica Nicolescu Lecture 9.
Kinetic data structures. Goal Maintain a configuration of moving objects Each object has a posted flight plan (this is essentially a well behaved function.
Chapter 2: Basic Data Structures. Spring 2003CS 3152 Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority.
Change Keys in heaps Fibonacci heap Zhao Xiaobin.
1 Binomial Tree Binomial tree. n Recursive definition: B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4.
CSS446 Spring 2014 Nan Wang.  to study trees and binary trees  to understand how binary search trees can implement sets  to learn how red-black trees.
Binary Tree. Some Terminologies Short review on binary tree Tree traversals Binary Search Tree (BST)‏ Questions.
1 Fat heaps (K & Tarjan 96). 2 Goal Want to achieve the performance of Fibonnaci heaps but on the worst case. Why ? Theoretical curiosity and some applications.
(2,4) Trees1 What are they? –They are search Trees (but not binary search trees) –They are also known as 2-4, trees.
CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)
AVL Trees and Heaps. AVL Trees So far balancing the tree was done globally Basically every node was involved in the balance operation Tree balancing can.
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
Lecture 10COMPSCI.220.FS.T Binary Search Tree BST converts a static binary search into a dynamic binary search allowing to efficiently insert and.
Kinetic Heaps K, Tarjan, and Tsioutsiouliklis. Broadcast Scheduling Parametric and Kinetic Heaps Broadcast Scheduling Using a Kinetic Heap The Computational.
1 Chapter 6 Heapsort. 2 About this lecture Introduce Heap – Shape Property and Heap Property – Heap Operations Heapsort: Use Heap to Sort Fixing heap.
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.
Review for Exam 2 Topics covered: –Recursion and recursive functions –General rooted trees –Binary Search Trees (BST) –Splay Tree –RB Tree –K-D Trees For.
Fibonacci Heap Fibonacci heapshave better asymptotic time bounds than binary heaps for the INSERT, UNION, and DECREASE-KEY operations, and they.
Fibonacci Heaps. Fibonacci Binary insert O(1) O(log(n)) find O(1) N/A union O(1) N/A minimum O(1) O(1) decrease key O(1) O(log(n)) delete O(log(n) O(log(n))
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Binomial heaps, Fibonacci heaps, and applications
Priority Queues © 2010 Goodrich, Tamassia Priority Queues 1
Heaps Binomial Heaps Lazy Binomial Heaps 1.
Source: Muangsin / Weiss
Heaps © 2010 Goodrich, Tamassia Heaps Heaps
Priority Queues MakeQueue create new empty queue
A simpler implementation and analysis of Chazelle’s
Tree Representation Heap.
© 2013 Goodrich, Tamassia, Goldwasser
ערמות בינומיות ופיבונצ'י
Binomial heaps, Fibonacci heaps, and applications
Binomial heaps, Fibonacci heaps, and applications
B-Trees.
CS 6310 Advanced Data Structure Wei-Shian Wang
Presentation transcript:

Four different data structures, each one best in a different setting. Simple Heap Balanced Heap Fibonacci Heap Incremental Heap Our results

A balanced binary tree, with items in the leaves in left-right order by decreasing key slope. The tree is a tournament on items by current key. Simple heap (highlights) We get O(log 2 n) for delete and insert O(1) for find-min All bounds are amortized

A better deletions only data structure Dynamize using the technique of Bently and Saxe Balanced heap (highlights) We get O(log n loglog n) for delete O(log n) for find-min and insert

Based one Fibonacci heaps with lazy linking. We link only when it is safe Fibonacci heap (highlights) We get O(log 2 n) for delete O(log n) for find-min and insert O(log n) for decrease-key

Incremental heap (highlights) Assumptions insertion of i: a i = 1, increase key of i: a i := a i + 1 Group items by key slope, each group is an ordinary Fibonacci heap Move items among groups as key slopes change (“displaced” items because entire subtrees are moved) We get find-max, insert : O(1) The k th increase-key : O(log min{k,n}) delete : O(log n)

A balanced binary tree, with items in the leaves in left-right order by decreasing key slope. The tree is a tournament on items by current key. Simple heap (details)

a b e d c a b d c e a a c a       

Simple kinetic heaps (Cont) Add swap times at internal nodes

a b e d c a b d c e a a c a       

Simple kinetic heaps (Cont) Add minimum future swap time

a b e d c a b d c e a a c a       

Simple kinetic heaps (Cont) When we do a find-min if the current time moves forward, we act as follows: Locate all nodes whose winner changes. The paths from the root to those nodes form a subtree. Update this subtree

a b e d c a b d c e a a c a       

a b e d c a b d c e a a c a       

a b e d c a b d c e b a c a               

a b e d c a b d c e b b  20 3        c a

a b e d c a b d c e b b  20 3        c b

a b e d c a b d c e b b c b         6.8

a b e d c a b d c e b b c b        

a b e d c a b d c e b b e e         20 3 

a b e d c a b d c e b b e e         3 

Simple kinetic heaps – insert & delete Use the regular mechanism of (say) red-black trees

a b e d c a b d c e b b e e f         

a b e d c a b d c e b b e e   f f f  -20       

a b e d c a b d c e b f e e     f f f  -20       

Simple kinetic heaps (analysis) Find-min takes O(1) time if we do not advance the current time. Advancing the current time can be expensive on the worst-case Amortization: Assign O(log n) potential to each node whose swap time is in the future. This potential pays for advancing the time. So find-min takes O(1) amortized time. Insert and delete take O(log 2 n) amortized time

How do we make this a parametric heap ? (Overmars-Van Leeuwen)

a b e d c a b c e        d

Looks like we use non linear space ? Each node keeps the chain of segments that are on its envelope but not on its parent envelope. This makes the space linear.

a b e d c a b c e        d

Analysis Using search trees to represent the envelopes sorted by slopes then: Find-min takes O(log n) time Insert and delete take O(log 2 n) time: You split and concatenate O(log n) such envelopes.

Balanced kinetic heaps Def: The level of a line is the depth of the highest node where it is stored. Plan: first we’ll do only deletions faster and then we’ll add insertions. Our starting point is the previous data structure.

Deletion-only data structure The level of a line is the depth of the highest node where it is stored.

a b e d c a b c e        d d

Deletion-only data structure What happens when we delete a line ?

a b e d c a b c e        d d

a b e d c a b e        d d

a b e d c a b e        d d

a b e d c a b e        d d

Balanced kinetic heaps When we delete a line, lines only decrease their level.

      

      

Analysis Key idea: Implement the envelopes using finger search trees How much time it takes to delete an element ? O(log n) +  log (# lines get on the replacement piece) +  log (# lines get off the replacement piece) If in all nodes # lines get on/off the replacement piece < log 2 n we are ok --- the delete takes O(log n loglog n) time However it could be that # lines get on/off the replacement piece > log 2 n

Analysis (Cont) If a line gets on the replacement piece it changes its level Since the total number of level changes is nlog(n) The number of chains of length > log 2 n is at most n/log(n) So the total work in moving long chain is O(n) and can be charged to the initialization phase.

A better deletions only data structure O(n) init. time and then O(log n loglog n) per delete. O(1) find-min if we are kinetic. Now we add insert. Summary so far

Balanced kinetic heaps (finalle) Balanced heaps (step 2): Use a well known reduction by Bently and Saxe to add insertions Maintain a binary counter of deletion only data structures

Balanced kinetic heaps Delete : O(log n loglog n) Insert : O(log n) Find-min : O(log n) (kinetic)

Based one Fibonacci heaps with lazy linking. We link only when it is safe Fibonacci heap (highlights) We get O(log 2 n) for delete O(log n) for find-min and insert O(log n) for decrease-key

Fibonacci Kinetic Heap Mimic Fibonacci heap, but only do links for permanent comparisons. Store unlinked tree roots of equal rank in a sorted list O(log n) find min, insert, decrease key, O(log 2 n) delete, amortized

Fibonacci heaps (Fredman & Tarjan 84) Want to do decrease-key(x,h,  ) faster than delete+insert. ( in O(1) time.)

Heap ordered (Fibonacci) trees

Linking Operations are defined via a basic operation, called linking, of Fibonacci trees: Produce a F k from two F k-1, keep heap order

Basic idea: delay the linking until they are safe S1S1 S0S0 SrSr  Regular heap

Linking The basic operation is inserting a tree of rank r into S r, making the appropriate linking if needed. Insert(i) : Insert a new node containing i into S 0 This may cascade, but we have one tree less every time we do the linking Decrease-key(i, a’.b’) : Decrease the key of i in the tree containing it making cascading cuts, link the resulting trees back into the structure.

Analysis Similar to the analysis of F-heaps Multiply the potential by log n

Incremental heap (highlights) Assumptions insertion of i: a i = 1, increase key of i: a i := a i + 1 Group items by key slope, each group is an ordinary Fibonacci heap Move items among groups as key slopes change (“displaced” items because entire subtrees are moved) We get find-max, insert : O(1) The k th increase-key : O(log min{k,n}) delete : O(log n)

Open problems Experiments: What is the best structure in practice? Better bounds: kinetic heaps in ordinary F-heap bounds? parametric heaps in O(log n) amortized time per operation? Simple kinetic heaps via splay trees?