Pre-Order Traversal
Learn the traversal strategy called "Pre-Order Traversal" in a binary search tree, and implement it in C#.
We'll cover the following
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:
-
Visit the current node, i.e., print the value stored at the node.
-
Call the
preOrderPrint()
function on the left-subtree of thecurrentNode
. -
Call the
preOrderPrint()
function on the right-subtree of thecurrentNode
.
Create a free account to view this lesson.
By signing up, you agree to Educative's Terms of Service and Privacy Policy