CMSC-341, Fall 1999, Sections 0101
Binary Search Trees
- BST Definition
- A Binary Search Tree is a Binary Tree in which, at every node V,
the value stored in the left child node is less that the value stored in V,
and the value stored in the right child node is greater than the value stored
in V.
- Search Tree ADT
A search tree is a BST in which homogeneous element are stored,
without duplicates. The tree is dynamic. Each BST contains a single object
called ITEM_NOT_FOUND which is guaranteed not to be an element of the tree.
The elements are ordered in the following ways
-
- in-order -- as dictated by operator <
- pre-order, post-order, level-order -- as dictated by the structure of the tree
Basic BST operations:
-
- BinarySearchTree (const Comparable& notFound) - constructor
- BinarySearchTree (constBinarySearchTree& rhs) - copy constructor
- ~BinarySearchTree ( ) - destructor
- const BinarySearchTree & operator= (const BinarySearchTree & rsh) - assignment
- const Comparable & find(const Comparable & x) const
- const Comparable & findMax ( ) const
- const Comparable & findMin ( ) const
Dennis Frey
Last modified: Sun Sep 26 20:53:25 EDT 1999