GeeksforGeeks » Interview Questions

Microsoft Interview Question for Software Engineer/Developer (Fresher) about Trees

(3 posts)
  • Started 2 years ago by geek4u
  • Latest reply from Aashish Barnwal

Tags:

  1. geek4u
    guest
    Posted 2 years ago #

    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.

  2. kartik
    Moderator
    Posted 2 years ago #

  3. Dedicated Programmer
    Member
    Posted 4 months ago #

    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.

RSS feed for this topic