As the code is already shared in the given link. I just wanna try explain
how it is ..
Struct Node {
Data d;
Struct Node *right;
Struct Node *left;
};
Thats the basic structure of the Link List. Now say U have a tree T with
root as the start node. Now we know the Simple Inorder traversal, which as
depicted in diagram, when reached to the left most child, Create a Node N (
and Hold its address and head ) , Copy data to this Node and visit its
parent. Create parent Node P and Now N->right=P and P->left=N. Again Create
Node N2 and visit its left child ( as inorder traversal) , so now
P->right=N2 and N2->left=P. it works excellent in a recursive way.
So when U reached to the last Node (i.e rightmost right when U break the
recursion) , jst make additional pointer modification. N(last
node)->right=head and head->left=N(last node)..
Just draw the pictorial representation. this is excellent problem yet not
that hard to resolve..
On Thu, May 24, 2012 at 11:20 PM, rahul r. srivastava <
[email protected]> wrote:
> hey people....
>
> can anyone explain the logic and solution(in simple words) behind the
> classical problem of converting binary tree to circular doubly linked list
> in inorder fashion.....
>
> stanford language seems to be way above my head....
> http://cslibrary.stanford.edu/109/TreeListRecursion.html
>
> thnx...
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/algogeeks/-/IyQsfiqEmdUJ.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.