It is simple to convert BST to sorted doubly link list
Just do inorder_traverse and add node into the linklist.

It is like following.

linklist_node *head=NULL;
mod_in_order(tree_node *root){
       tree_node *temp;
       temp=root;

      if (root is a leaf node)
            add_node_to_linklist(root);   // instead of printing add
node
      else {
                if(root->left)
                       inorder(root->left);
               add_node_to_linklist(root);  // instead of printing add
node
               if(temp->right)
                       inorder(root->right);
     }

}



On Jul 25, 2:27 pm, jalaj jaiswal <jalaj.jaiswa...@gmail.com> wrote:
> @ above have it
> node * bsttolist(node *root){
>           if(root==NULL) return NULL;
>           node *l=bsttolist(root->left);
>           node *r=bsttolist(root->right);
>           root->left=root;
>           root->right=root;
>           append(l,root);
>           append(l,r);
>           return l;
>
> }
>
> here append function merges two circular doubly linked lists , you can make
> that on your own
>
> On Sun, Jul 25, 2010 at 1:35 PM, Debajyoti Sarma
> <sarma.debajy...@gmail.com>wrote:
>
>
>
> > @rahul
> > how to convert bst ot doubly linked list.
> > I m understanding the logic but not able to code
> > give a pseudo code to understand.
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Algorithm Geeks" group.
> > To post to this group, send email to algoge...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/algogeeks?hl=en.
>
> --
> With Regards,
> Jalaj Jaiswal
> +919026283397
> B.TECH IT
> IIIT ALLAHABAD

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algoge...@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.

Reply via email to