Algorithm for Preorder Traversal of Binary Tree

The algorithm for preorder traversal is shown as follows:

Preorder(root):

  1. Follow step 2 to 4 until root != NULL
  2. Write root -> data
  3. Preorder (root -> left)
  4. Preorder (root -> right)
  5. End loop

Preorder Traversal of Binary Tree

Preorder traversal is defined as a type of tree traversal that follows the Root-Left-Right policy where:

  • The root node of the subtree is visited first.
  • Then the left subtree  is traversed.
  • At last, the right subtree is traversed.

Preorder traversal

Similar Reads

Algorithm for Preorder Traversal of Binary Tree

The algorithm for preorder traversal is shown as follows:...

How does Preorder Traversal of Binary Tree work?

Consider the following tree:...

Program to Implement Preorder Traversal of Binary Tree

Below is the code implementation of the preorder traversal:...

Contact Us