Skip to content

Binary Search Trees

Traversal

Inorder Traversal

Video

Procedure:

  • Traverse Left subtree
  • Visit node
  • Traverse Right subtree
public static void inOrder(Node root) {
        if (root == null){
            return;
        }
        inOrder(root.left);
        System.out.print(root.data + " ");
        inOrder(root.right);
    }

Preorder Traversal

Video

Procedure:

  • Visit node
  • Traverse Left subtree
  • Traverse Right subtree

Postorder Traversal

Video

Procedure:

  • Traverse Left subtree
  • Traverse Right subtree
  • Visit node