This is my implementation of finding the smallest search key in a BST using two different ways and I'd like to make sure if I'm doing it correctly:
Iterative
public T findSmallest ( BinarySearchTree<T> tree )
{ BinaryNode Node = new BinaryNode (tree.getDataRoot);
if ( Node == null ) return null;
while(Node.hasLeftChild()) Node = Node.getLeftChild;
return Node.getData(); }
Recursively
public T findSmallest ( BinaryNode Node )
{ if (Node == null) return null;
if(Node.getLeftChild()==null) return Node.getData();
else
return findSmallest ( (Node.getLeftChild()) ; }