Pre-Order Traversal

Learn the traversal strategy called "Pre-Order Traversal" in a binary search tree, and implement it in C#.

Introduction

In this traversal, the elements are traversed in the root-left-right order. First visit the root/parent node, then the left child. Then visit the right child. Here is a high-level description of the algorithm for pre-order traversal starting from the root node:

  1. Visit the current node, i.e., print the value stored at the node.

  2. Call the preOrderPrint() function on the left-subtree of the currentNode.

  3. Call the preOrderPrint() function on the right-subtree of the currentNode.

Create a free account to view this lesson.

By signing up, you agree to Educative's Terms of Service and Privacy Policy