On Thu, Nov 25, 2010 at 11:05 PM, mo...@ismu <[email protected]> wrote:
>
> node *bst_to_dl(root)
> {
> node *head1=NULL,head2=NULL,*temp=NULL;
> temp=(node *)calloc(1,sizeof(node));
> temp->value=root->value;
> if(root-left)
> head1=bst_to_dl(root-left);
> if (root->right)
> head2=bst_to_dl(root->right);
> if(head2&&head1)//root having two children
> {
> head1->next=head2;
> head2->prev=head1;
> temp->next=head1;
> head1->prev=temp;
> }
> else if(head1) //root having only one child
> {
> temp->next=head1;
> head1->prev=temp;
> }
>
else if(head2)
{
temp->next=head2;
head2->prev=temp;
}
> return temp;
> }
>
>
--
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.