Binary Search Tree (BST) Traversals

BST Traversals

Binary Search Tree (BST) traversals are methods of systematically visiting each node in a BST. 

There are three common types of traversals:

Inorder Traversal

Inorder Traversal:


In pseudo-code, the inorder traversal algorithm can be represented as:

inorder(node):

    if node is not None:

        inorder(node.left)

        visit(node)

        inorder(node.right)

Preorder Traversal

Preorder Traversal:

In pseudo-code, the preorder traversal algorithm can be represented as:

preorder(node):

    if node is not None:

        visit(node)

        preorder(node.left)

        preorder(node.right)


Postorder Traversal

Postorder Traversal:

In pseudo-code, the postorder traversal algorithm can be represented as:

postorder(node):

    if node is not None:

        postorder(node.left)

        postorder(node.right)

        visit(node)