Part 7 of 15 in Binary Trees  

Preorder traversal of binary tree by animeshn

Problem statement

Given pointer to the root node of a binary tree of integers, write a function to print elements of the tree in its pre-order traversal.

Input

You need to write a function named "Preorder" that will take root of a binary tree of integers as argument. you need to output using cout, and one element per line. you can assume that the headeriostream is already imported.

Output

Your function should print all the elements in the binary tree in its pre-order traversal.



To try out your code



Sign in

Sign up