Just do inorder traversal and change d links.. D code is as below...
//Change last->right = head and
// head->left = last in main to make it a circular list
void BSTtoCDbl(List *root,List **head,List** last)
{
if(!root) return;
BSTtoCDbl(root->left,head,last);
if(*last == NULL)
{
*head = root;
*last = *head;
}
else
{
(*last)->right = root;
root->left = *last;
*last = root;
}
BSTtoCDbl(root->right,head,last);
}
On Mon, Jun 21, 2010 at 1:55 PM, jalaj jaiswal <[email protected]>wrote:
> CAN ANY 1 GIVE THE ALGORITHM.. HOW TO CONVERT BST TO dLL
>
> --
> 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
Simplicity is prerequisite for reliability.
– Edsger W. Dijkstra
--
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.