AvlTree - package DataStructures BinarySearchTree class CONSTRUCTION with no initializer*PUBLIC OPERATIONS void insert x-> Insert x void remove x->

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

View Full Document Right Arrow Icon
package DataStructures; // BinarySearchTree class // // CONSTRUCTION: with no initializer // // ******************PUBLIC OPERATIONS********************* // void insert( x ) --> Insert x // void remove( x ) --> Remove x (unimplemented) // Comparable find( x ) --> Return item that matches x // Comparable findMin( ) --> Return smallest item // Comparable findMax( ) --> Return largest item // boolean isEmpty( ) --> Return true if empty; else false // void makeEmpty( ) --> Remove all items // void printTree( ) --> Print tree in sorted order /** * Implements an AVL tree. * Note that all "matching" is based on the compareTo method. * @author Mark Allen Weiss */ public class AvlTree { /** * Construct the tree. */ public AvlTree( ) { root = null; } /** * Insert into the tree; duplicates are ignored. * @param x the item to insert. */ public void insert( Comparable x ) { root = insert( x, root ); } /** * Remove from the tree. Nothing is done if x is not found. * @param x the item to remove. */ public void remove( Comparable x ) { System.out.println( "Sorry, remove unimplemented" ); } /** * Find the smallest item in the tree. * @return smallest item or null if empty. */ public Comparable findMin( ) { return elementAt( findMin( 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
* Find the largest item in the tree. * @return the largest item of null if empty. */ public Comparable findMax( ) { return elementAt( findMax( root ) ); } /** * Find an item in the tree. * @param x the item to search for. * @return the matching item or null if not found.
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 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 / 6

AvlTree - package DataStructures BinarySearchTree class CONSTRUCTION with no initializer*PUBLIC OPERATIONS void insert x-> Insert x void remove x->

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