LeftistHeap - package DataStructures LeftistHeap class...

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

View Full Document Right Arrow Icon
package DataStructures; // LeftistHeap class // // CONSTRUCTION: with a negative infinity sentinel // // ******************PUBLIC OPERATIONS********************* // void insert( x ) --> Insert x // Comparable deleteMin( )--> Return and remove smallest item // Comparable findMin( ) --> Return smallest item // boolean isEmpty( ) --> Return true if empty; else false // boolean isFull( ) --> Return false in this implementation // void makeEmpty( ) --> Remove all items // void merge( rhs ) --> Absorb rhs into this heap /** * Implements a leftist heap. * Note that all "matching" is based on the compareTo method. * @author Mark Allen Weiss */ public class LeftistHeap { /** * Construct the leftist heap. */ public LeftistHeap( ) { root = null; } /** * Merge rhs into the priority queue. * rhs becomes empty. rhs must be different from this. * @param rhs the other leftist heap. */ public void merge( LeftistHeap rhs ) { if( this == rhs ) // Avoid aliasing problems return; root = merge( root, rhs.root );
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/22/2011 for the course CSC 532 taught by Professor Dr.gursaranadhar during the Spring '07 term at University of North Carolina Wilmington.

Page1 / 3

LeftistHeap - package DataStructures LeftistHeap class...

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

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