Challenge: Print Pre-Order Traversal

Let’s print the pre-order traversal of a tree.


Given a binary tree, perform a pre-order traversal by completing the PrintPreOrder() function. A pre-order traversal is a traversal in which a node is visited first, then its left child, and finally its right child.


A binary tree.


Display pre-order traversal of the tree on the console.

Sample input

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.