//can be improved by having a function to join 2 DLLs struct node *tree2DLL(struct node * pRoot) { if (!pRoot) return NULL; struct node *pleftDLL = tree2DLL(pRoot->left); struct node *pRightDLL = tree2DLL(pRoot->right); //now join left with root
pLeftDLL->left->right = pRoot; pRoot->left = pleftDLL->left; pRoot->right= pLeftDLL; pLeftDLL->left = pRoot; //now join pLeftDLL and pRightDLL; struct node* pTemp = pRightDLL->left; pLeftDLL->left->right = pRightDLL; pRightDLL->left = pLeftDLL->left; pTemp->right = pLeftDLL; pLeftDLL->left = pTemp; return pLeftDLL; } Best Regards Ashish Goel "Think positive and find fuel in failure" +919985813081 +919966006652 On Thu, May 24, 2012 at 11:20 PM, rahul r. srivastava < rahul.ranjan...@gmail.com> 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 algogeeks@googlegroups.com. > To unsubscribe from this group, send email to > algogeeks+unsubscr...@googlegroups.com. > 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 algogeeks@googlegroups.com. To unsubscribe from this group, send email to algogeeks+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.