The Great Tree-List Recursion Problem

write a recursive function to convert a BST into sorted doubly linked
list.

Comments

  1. node * bst(node *p,node *parent=null){
    node *q=null,*prev,*next,*t;
    if(p==null)
    return q;

    bst(p->left,parent);
    t=malloc(sizeof(node));
    t->prev=null;
    t->next=null;
    t->value=p->value;
    parent=t;
    if(q==null)
    {q=t;
    }
    else{
    parent->next=t;
    t->prev=parent;
    t->next=null;
    }
    bst(p->right,parent);
    return q;
    }

    ReplyDelete
  2. http://cslibrary.stanford.edu/109/TreeListRecursion.html#c

    ReplyDelete

Post a Comment

Popular posts from this blog