I have seen some articles/pages on how to connect the nodes of an binary tree which are at same level but none of those articles explain the process/algorithm clearly. I would appreciate if someone can take this up. Code is not necessary, but explaining it with pseudo will be nice.
For the sake of discussion, let us consider tree as:
0
1 2
3 4 5 6
7 9
In above case:
0 should point to null.
1 should point to 2.
3 should point to 4.
....
7 should point to 9.
9 should point to NULL.
Basic tree structure is:
class Tree {
public:
int data;
Tree* left;
Tree* right;
Tree* next;
}
nextofprevious nodewill becurrently parsednode.