Consider the Binary Tree:
Pre-order traversal(root) is traversing the node then left sub-tree of the node and then the right sub-tree of the node.
So the pre-order traversal of above tree will be:
1 2 4 5 3 6 7
In-order traversal(root) is traversing the left sub-tree of the node then the node ...
For example if the given tree is:
Level order traversal will be
1 2 3 4 5 6 7
Printing node data level by level.
Code:
#include<iostream>
#include<queue>
#include<malloc.h>
using namespace std;
struct node{
int data;
node *left;
node *right;
};
...