Given a Binary Tree, print the nodes of a binary tree in a pre-order fashion.
Video coming soon!
Subscribe for more updates
Preparing for interviews? IDeserve team is here to help.
Create your profile
Create your profile, and here is what you will get:
1: Interview practice platform.
2: Once you are ready to take the interview, IDeserve team will help you get connected to the best job opportunities.
3: Personalized mentorship from IDeserve team once your interview process has started.
Creation of profile shouldn't take more than 2 minutes.
In the pre-order traversal for a given node 'n', 1. We first visit the node 'n' itself. 2. Then we traverse left-subtree of 'n' by calling printPreorder(n.left) 3. And finally we traverse right-subtree of 'n' by calling printPreorder(n.right)
Please check out the code section(printPreorder()) with visualization for illustration.
Support us by whitelisting IDeserve in your ad-blocker.