Page 153 - DCAP605_ADVANCED_DATA_STRUCTURE_AND_ALGORITHMS
P. 153
Advanced Data Structure and Algorithms
Notes
/**
* Returns true if x is found in the tree.
*/
bool contains( const Comparable & x, int &comps ) const
{
return contains( x, root, comps);
}
/**
* Test if the tree is logically empty.
* Return true if empty, false otherwise.
*/
bool isEmpty( ) const
{
return root == NULL;
}
/**
* Print the tree contents in sorted order.
*/
void printTree( ) const
{
if( isEmpty( ) )
cout << “Empty tree” << endl;
else
printTree( root );
}
/**
* Make the tree logically empty.
*/
void makeEmpty( )
{
makeEmpty( root );
}
/**
* Insert x into the tree; duplicates are ignored.
*/
148 LOVELY PROFESSIONAL UNIVERSITY