All algorithms

BST Traversal (in / pre / post)

Depth-first traversals of a binary search tree. In-order yields sorted values; pre-order is useful for copying; post-order for tree deletion and expression evaluation.

time O(n)
space O(h)

Press Tab out of the box or click Resetto regenerate frames from the current input.

Visualization
No frames yet — edit input and click Run.
Pseudocode
inorder(n):  inorder(n.left);  visit(n); inorder(n.right)
preorder(n): visit(n); preorder(n.left); preorder(n.right)
postorder(n):postorder(n.left); postorder(n.right); visit(n)