All pastes #344998 Raw Edit

Unnamed

public text v1 · immutable
·published 2007-02-08 04:35 UTC
rendered paste body
/*
 * TernaryHeap.java
 * 
 * Version:
 *     $Id$
 *
 * Revisions:
 *     $Log$
 */

/**
 * Generic implementation of a ternary heap. Items are arranged such that
 * each item in heap is less than its children in the heap.
 *
 * @author <YOUR NAME>
 */

public class TernaryHeap<E extends Comparable<E>> {
     

        /**
         * Constructor of an empty heap
         * 
         * @param       init    An empty array of the appropriate type, 
         *                      large enough to hold the heap at all times
         */
         
        public TernaryHeap(E[] init) {
        }

        /**
         * Returns the number of items in the heap.
         *
         * @return      Size of the heap
         */
      
        public int size() {
        }

        /**
         * Insert an item into the heap.
         *
         * @param       Item    item to insert
         */

         public void insert(E item) {
         }

        /**
         * Remove and return the item at the root of the heap.
         *
         * @return      the smallest item in the heap.
         * @exception   UnderflowException      If the heap is empty
         */
 
         public E remove() throws UnderflowException {
         }

        /**
         * Returns the String representation of the heap for testing. This
         * consists of each element's String representation on a line by
         * itself, in order reading across each level of the heap from top 
         * to bottom
         * 
         * @return      the String representation of the heap
         */
        
        public String toString() {
        }

} //TernaryHeap