GeeksforGeeks » Interview Questions
Microsoft Interview Question for Software Engineer/Developer (Fresher) about Trees
(3 posts)-
2. Write a C program to convert a BST (Bin search tree) into DLL (Doubly Linked List) of increasing nodes values. The constraint is to write a recursive program, no other solution will be accepted.
-
void convertToDLL(struct node *root,struct node **start)
{
static struct node *prev;
if(root)
{
convertToDLL(root->left,start);
if(!(*start))
*start=root;
else
{
root->left=prev;
prev->right=root;
}
prev=root;
convertToDLL(root->right,start);
}
}
Reply
You must log in to post.