Visualize binary search trees, node path traversals, element insertions, and structural node deletions.
Where h is the height of the tree. Traverses the depth of the tree to find the correct leaf node location.
Occupies O(h) recursion stack space. Storing/updating node pointers recursively consumes depth-related call stacks.
Node insert(Node root, int key) {if (root == null)
return new Node(key);
if (key < root.key)
root.left = insert(root.left, key);
else if (key > root.key)
root.right = insert(root.right, key);
return root;
}