This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Jubilee lecture, October 2004/January 2005 Title: Anatomy of a worstcase efficient priority queue Speaker: Jyrki Katajainen Coworkers: Amr Elmasry and Claus Jensen These slides are available at http://www.cphstl.dk/ . c circlecopyrt Performance Engineering Laboratory 1 Priority Queues Types E : elements manipulated C : compartments where elements are stored F : ordering used in element comparisons A : allocator used in memory management Assumptions • The elements are only moved and com pared, both operations having a cost of O (1). • It is possible to get any information stored at a compartment at a cost of O (1). • Both allocation and deallocation have a cost of O (1). c circlecopyrt Performance Engineering Laboratory 2 PriorityQueue Operations Let Q be a priority queue with type parame ters (E , C , F , A) . E findmin(): Return a minimum element stored in Q . The minimum is taken with respect to F . C insert( E e ): Insert element e into Q and return its compartment for later use. void deletemin(): Remove a minimum ele ment and its compartment from Q . void delete( C p ): Remove both the element stored at compartment p and p from Q . void decrease( C p , E e ): Replace the el ement stored at compartment p with a smaller element e . void unite( priority queue (E , C , F , A) R ): Move all elements stored in R to Q . Some additional operations like a construc tor, a destructor, empty(), and size() are nec essary to make the data structure useful. c circlecopyrt Performance Engineering Laboratory 3 Warning When an element is inserted, the reference to the compartment, where it is stored, should remain the same so that possible later ref erences made by delete and decrease opera tions are valid. Our solution to this potential problem is simple: we do not move the elements after they have been inserted into the data struc ture. In the C ++ standard this is called iterator validity . c circlecopyrt Performance Engineering Laboratory 4 Comparison of Priority Queues operation binary heap worst case Fibonacci heap amortized pruned binomial queue worst case findmin Θ(1) Θ(1) Θ(1) insert Θ(lg n ) Θ(1) Θ(1) deletemin Θ(lg n ) Θ(lg n ) Θ(lg n ) delete Θ(lg n ) Θ(lg n ) Θ(lg n ) decrease Θ(lg n ) Θ(1) Θ(1) unite Θ( n ) Θ(1) Θ(lg n ) n denotes the number of elements in the data structure just prior to the operation. c circlecopyrt Performance Engineering Laboratory 5 C ++ Standard The following complexity requirements — no other time or space bounds — are given. findmin(): constant time insert(): at most lg n element comparisons deletemin(): at most 2lg n element com parisons general constructor: at most 3 n element comparisons priorityqueue sort: at most n lg n element comparisons....
View
Full Document
 Fall '11
 potter
 Physiology, Anatomy, Binary heap, Fibonacci heap, binomial heap, Priority queue, c Performance Engineering Laboratory

Click to edit the document details