„Policy-Based Benchmarking of Weak Heaps and Their Relatives“ Asger Bruun*, Stefan Edelkamp, Jyrki Katajainen*, Jens Rasmussen* *University of Copenhagen.

Slides:



Advertisements
Similar presentations
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)
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
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
Priority Queues. Container of elements where each element has an associated key A key is an attribute that can identify rank or weight of an element Examples.
BST Data Structure A BST node contains: A BST contains
Chapter 6: Priority Queues Priority Queues Binary Heaps Mark Allen Weiss: Data Structures and Algorithm Analysis in Java Lydia Sinapova, Simpson College.
Rank-Pairing Heaps Bernhard Haeupler, Siddhartha Sen, and Robert Tarjan, ESA
Nick Harvey & Kevin Zatloukal
Dijkstra/Prim 1 make-heap |V| insert |V| delete-min |E| decrease-key Priority Queues make-heap Operation insert find-min delete-min union decrease-key.
Priority Queues. Container of elements where each element has an associated key A key is an attribute that can identify rank or weight of an element Examples.
Priority Queues1 Part-D1 Priority Queues. Priority Queues2 Priority Queue ADT (§ 7.1.3) A priority queue stores a collection of entries Each entry is.
Cpt S 223 – Advanced Data Structures Course Review Midterm Exam # 2
5.9 Heaps of optimal complexity
Dr. Andrew Wallace PhD BEng(hons) EurIng
Heaps and heapsort COMP171 Fall 2005 Part 2. Sorting III / Slide 2 Heap: array implementation Is it a good idea to store arbitrary.
B-Trees (continued) Analysis of worst-case and average number of disk accesses for an insert. Delete and analysis. Structure for B-tree node.
Binomial Heaps Jyh-Shing Roger Jang ( 張智星 ) CSIE Dept, National Taiwan University.
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.
UMass Lowell Computer Science Analysis of Algorithms Prof. Karen Daniels Fall, 2001 Lecture 11 Tuesday, 12/4/01 Advanced Data Structures Chapters.
1 Chapter 8 Priority Queues. 2 Implementations Heaps Priority queues and heaps Vector based implementation of heaps Skew heaps Outline.
Princeton University COS 423 Theory of Algorithms Spring 2002 Kevin Wayne Binary and Binomial Heaps These lecture slides are adapted from CLRS, Chapters.
1 Priority Queues (Heaps)  Sections 6.1 to The Priority Queue ADT  DeleteMin –log N time  Insert –log N time  Other operations –FindMin  Constant.
Heapsort Based off slides by: David Matuszek
CS 3610 Midterm Review.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
Chapter 21 Binary Heap.
Chapter 11 Heap. Overview ● The heap is a special type of binary tree. ● It may be used either as a priority queue or as a tool for sorting.
Computer Sciences Department1. Sorting algorithm 3 Chapter 6 3Computer Sciences Department Sorting algorithm 1  insertion sort Sorting algorithm 2.
Chapter 21 Priority Queue: Binary Heap Saurav Karmakar.
Review for Final Andy Wang Data Structures, Algorithms, and Generic Programming.
An experimental study of priority queues By Claus Jensen University of Copenhagen.
Chapter 2: Basic Data Structures. Spring 2003CS 3152 Basic Data Structures Stacks Queues Vectors, Linked Lists Trees (Including Balanced Trees) Priority.
1 Joe Meehean.  We wanted a data structure that gave us... the smallest item then the next smallest then the next and so on…  This ADT is called a priority.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
The ADT Table The ADT table, or dictionary Uses a search key to identify its items Its items are records that contain several pieces of data 2 Figure.
Change Keys in heaps Fibonacci heap Zhao Xiaobin.
+ David Kauchak cs312 Review. + Midterm Will be posted online this afternoon You will have 2 hours to take it watch your time! if you get stuck on a problem,
1 Binomial Tree Binomial tree. n Recursive definition: B k-1 B0B0 BkBk B0B0 B1B1 B2B2 B3B3 B4B4.
Data Structure II So Pak Yeung Outline Review  Array  Sorted Array  Linked List Binary Search Tree Heap Hash Table.
CS223 Advanced Data Structures and Algorithms 1 Priority Queue and Binary Heap Neil Tang 02/09/2010.
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.
Two-tier relaxed heaps Presented by Claus Jensen Joint work with Amr Elmasry and Jyrki Katajainen Slides available at
CMSC 341 Binomial Queues and Fibonacci Heaps. Basic Heap Operations OpBinary Heap Leftist Heap Binomial Queue Fibonacci Heap insertO(lgN) deleteMinO(lgN)
FALL 2005CENG 213 Data Structures1 Priority Queues (Heaps) Reference: Chapter 7.
Mergeable Heaps David Kauchak cs302 Spring Admin Homework 7?
CompSci 100e 8.1 Scoreboard l What else might we want to do with a data structure? AlgorithmInsertionDeletionSearch Unsorted Vector/array Sorted vector/array.
HeapSort 25 March HeapSort Heaps or priority queues provide a means of sorting: 1.Construct a heap, 2.Add each item to it (maintaining the heap.
1Computer Sciences. 2 HEAP SORT TUTORIAL 4 Objective O(n lg n) worst case like merge sort. Sorts in place like insertion sort. A heap can be stored as.
Heaps © 2010 Goodrich, Tamassia. Heaps2 Priority Queue ADT  A priority queue (PQ) stores a collection of entries  Typically, an entry is a.
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.
Fibonacci Heap Fibonacci heapshave better asymptotic time bounds than binary heaps for the INSERT, UNION, and DECREASE-KEY operations, and they.
1 Priority Queues (Heaps). 2 Priority Queues Many applications require that we process records with keys in order, but not necessarily in full sorted.
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))
Final Exam Review COP4530.
Data Structures Binomial Heaps Fibonacci Heaps Haim Kaplan & Uri Zwick
Experimental evaluation of Navigation piles
Data Structures & Algorithms
Heaps © 2010 Goodrich, Tamassia Heaps Heaps
Heap Sort Example Qamar Abbas.
Priority Queue & Heap CSCI 3110 Nan Chen.
CMSC 341 Lecture 14 Priority Queues & Heaps
Tree Representation Heap.
Strict Fibonacci Heaps
Binary and Binomial Heaps
Topic 5: Heap data structure heap sort Priority queue
Priority Queues Supports the following operations. Insert element x.
Heaps & Multi-way Search Trees
CMPT 225 Lecture 16 – Heap Sort.
Presentation transcript:

„Policy-Based Benchmarking of Weak Heaps and Their Relatives“ Asger Bruun*, Stefan Edelkamp, Jyrki Katajainen*, Jens Rasmussen* *University of Copenhagen

Priority-Queue Operations

Market Analysis

Looking at Constants… Further Engineering  Policy-Based Benchmarking…  Methodology (Policy-Based Benchmarking) Results Highlights (LEDA vs. CPH-STL) Lessons Learnt

Generic Component Frameworks in the CPH STL C++ template design: useful to carry out unbiased experiments & (micro-)benchmarking  interfaces are decoupled from their implementations Clear division of labour:  Containers de/allocate nodes  Realizators extract nodes and work on them (Unidirectional) Iterators traverse through the elements and are used as handles to elements

(Perfect) Weak-Heaps A (perfect) Weak Heap is a binary tree where:  the root has no left subtree  the right subtree of the root is a balanced (complete) binary tree  each element is smaller than the element on its left „spine“ Observation: 1-to-1 mapping between nodes in heap-ordered binomial trees and perfect weak heaps

Single-Heap Framework Resizable Array: For iterators validity, store elements indirectly & maintain pointers between array and elements (does not destroy worst-case complexity!) Heap Structure: different heapifier policies allow switching between weak heaps and different implementations of binary heaps (e.g., alternative bottom-up sift-down strategy)

Joining/Merging and Splitting

Heap Store A heap store is a sequence of perfect weak heaps Joins are delayed using redundant number representation

Insert (node p) 1. 2.

Multiple-Heap Framework Node: 2 pointers per node are sufficient to cover the parent- child relationships, but this space optimization costs execution time Heap Store: list of proxies was slower than maintaining the roots in a linked list by reusing the pointers at the nodes, where the heights of the heaps are maintained in a bit vector

Node Store maintains heap-order violating marked nodes efficiently  worst case for mark, unmark, and reduce is O(1)

Transformations  Cleaning:  Parent:  Sibling: Pair:  Run (reduces 1 marking, max. 3 comps)  Singleton (reduces 1 marking, max. 3 comps)

Decrease (at node p)

Delete (node p)

Relaxed-Heap Framework Node Store: doubly-linked lists of leaders, and singletons at each height too slow  Engineering: array of bit vectors, each occupying a single word, indicating which of the marked nodes are singletons (access via most significant bit) Rank Relaxation: apply transformations eagerly  2 bitvectors

Insert (in sorted order)

Results: Decrease (to top-1)

Results: Delete (random position)

Results: Delete-Min (in random heap)

LEDA vs. CPH STL (Dijkstra‘s SSSP)  CPH STL bin heap cmps 34.45s  CPH STL weak heap cmps 34.45s  CPH STL weak queue cmps 29.70s  CPH STL run relaxed cmps 35.98s  CPH STL rank relaxed cmps 33.69s  LEDA pairing heap cmps 36.72s  LEDA Fibonacci heap cmps 47.03s (Hot: CPH STL Fibonacci heaps cmps 30.87s)

Lessons Learnt (1) 1) Read the masters: the original implementation of a binomial queue of Vuillemin, in essence a weak queue, turned out to be one of the best performers. 2) PQs that guarantee good performance in the worst-case setting have difficulties in competing against solutions that guarantee good performance in the amortized setting. 3) Memory management is expensive: in our early code many unnecessary memory allocations were performed.

Lessons Learnt (2) 4) For most practical values of n, the difference between lg n and O(1) is small; e.g. for heaps, the loop sifting up an element is extremely tight. 5) For random data, the typical running time of insert, decrease, and delete is O(1) for binary heaps, weak heaps, and weak queues. 6) Generic component frameworks help algorithm engineers to carry out unbiased experiments

Thanks