Given a Binary Tree consisting of** N** nodes, the task is to print its Double Order Traversal.
Double Order Traversal_ is a tree traversal technique in which every node is traversed twice in the following order: _
Examples:
Input:
1
/ \
7 3
/ \ /
4 5 6
Output: 1 7 4 4 7 5 5 1 3 6 6 3
Input:
1
/ \
7 3
/ \ \
4 5 6
Output: 1 7 4 4 7 5 5 1 3 3 6 6
Recommended: Please try your approach on {IDE} first, before moving on to the solution.
Approach:
The idea is to perform Inorder Traversal recursively on the given Binary Tree and print the node value on **visiting a vertex **and after the recursive call to the left subtree during the traversal.
Follow the steps below to solve the problem:
#data structures #recursion #tree #binary tree #inorder traversal #data analysis