


























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



























Department of Computer Science โ University of San Francisco โ p.1/
To find the minimal element in a BST:^ Base Case: When is it easy to find the smallest element ina BST?^ Recursive Case: How can we make the problem smaller?How can we use the solution to the smaller problem tosolve the original problem?
Department of Computer Science โ University of San Francisco โ p.2/
To find the minimal element in a BST:Base Case:^ When is it easy to find the smallest element in a BST?^ When the left subtree is empty, then the elementstored at the root is the smallest element in the tree.
Department of Computer Science โ University of San Francisco โ p.4/
To find the minimal element in a BST:Recursive Case:^ How can we make the problem smaller?
Department of Computer Science โ University of San Francisco โ p.5/
To find the minimal element in a BST:Recursive Case:^ How can we make the problem smaller?^ Both the left and right subtrees are smaller versions ofthe same problem^ How can we use the solution to a smaller problem to solvethe original problem?^ The smallest element in the left subtree is the smallestelement in the tree
Department of Computer Science โ University of San Francisco โ p.7/
Object^ minimum(Node
tree)^ { if (tree ==^ null)return null;if (tree.left()^ ==
null)return tree.element(); elsereturn minimum(tree.left());}
Department of Computer Science โ University of San Francisco โ p.8/