1. Start at the root node Loop while current node is non-null
  2. If the current node’s value is equal to your value Return the current node
  3. If the current node’s value is less than your value Make the right node your current node
  4. If the current node’s value is greater than your value Make the left node your current node
  5. End loop

 

Java implementation

 

 

Node findNode(Node root, int value)
{
while(root!=null)
{
int current = root.getValue();
if(current == value) break;
if(current right
else root = root->left;
}
return root;
}

Advertisements