BinaryHeap - package DataStructures BinaryHeap class CONSTRUCTION with optional capacity(that defaults to 100*PUBLIC OPERATIONS void insert x->

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

View Full Document Right Arrow Icon
package DataStructures; // BinaryHeap class // // CONSTRUCTION: with optional capacity (that defaults to 100) // // ******************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 true if full; else false // void makeEmpty( ) --> Remove all items // ******************ERRORS******************************** // Throws Overflow if capacity exceeded /** * Implements a binary heap. * Note that all "matching" is based on the compareTo method. * @author Mark Allen Weiss */ public class BinaryHeap { /** * Construct the binary heap. */ public BinaryHeap( ) { this( DEFAULT_CAPACITY ); } /** * Construct the binary heap. * @param capacity the capacity of the binary heap. */ public BinaryHeap( int capacity ) { currentSize = 0; array = new Comparable[ capacity + 1 ]; } /** * Insert into the priority queue, maintaining heap order. * Duplicates are allowed.
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 document was uploaded on 06/13/2011.

Page1 / 4

BinaryHeap - package DataStructures BinaryHeap class CONSTRUCTION with optional capacity(that defaults to 100*PUBLIC OPERATIONS void insert x->

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