Introduction to Algorithms, Second Edition

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon
The University of Texas at Austin Lecture 15 Department of Computer Sciences Professor Vijaya Ramachandran Priority Queue; Heapsort CS357: ALGORITHMS, Spring 2006 1 Data Structures Sets manipulated by algorithms often grow, shrink or change over time, so we call these dynamic sets . To represent such dynamic sets and to manipulate them eFciently, we need to design good data structures . Over the next several classes we will look at several important data structures. We start with priority queue . 2 Priority Queue A priority queue maintains a dynamic set S of elements from a totally ordered set, so that the following operations can be performed eFciently: Insert ( S, x ): inserts element x , whose key value is given. Minimum ( S ): returns a pointer to an element in S with minimum key. Extract-min ( S ): returns an element with minimum key in S , and deletes that ele- ment from the priority queue. We often use an augmented priority queue that supports the following two operations, in addition to the three operations listed above. Decrease-key ( S, x, k ): given a pointer to element x in S , updates the key value of element x to min( key ( x ) , k ). Delete ( S, x ): given a pointer to element x in S , removes x from S . (One can also de±ne a ‘max-priority-queue’ in which the ‘Minimum’ and ‘min’ in the above operations are replaced by ‘Maximum’ and ‘max’.)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2.1 Binary Heap A heap structure on n elements is an ordered binary tree on n nodes that is as complete as possible; if the lowest level is not full, then it is Flled in completely from the left end. ±or a node v in this binary tree, we denote its left child by left ( v ), its right child by right ( v ), and its parent by parent ( v ) or p ( v ). We use NIL to denote that a Feld is empty.
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 01/30/2008 for the course CS 357 taught by Professor Ramachandran during the Spring '06 term at University of Texas at Austin.

Page1 / 4

Lecture 15 - The University of Texas at Austin Department...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online