Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8500191
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T00:52:42+00:00 2026-06-11T00:52:42+00:00

As mentioned in the Title , I have a Binary search tree. I want

  • 0

As mentioned in the Title , I have a Binary search tree. I want to convert it to sorted doubly linklist using recursion.

My code

 for each node in tree
   find max of left sub-tree and assign its right to present node ,present node left to max 
   find min of right sub-tree and assign its left to present node ,present node right to max 
   and now recursively do same thing to other nodes in BST .

but this solution is not efficient as it reaches each node more than one time .In my quest of optimized code i got a link from google greatTreeList sollution . I have searched the same in SO both sollutions are same and worked for me. I didnt understand the append function of the sollution as it contains code

join(alast,b)
join(blast,a)

For tree whose nodes are inserted in following order 10,5,9,6,8,7,12,11,13,14

can anyone please explain how
join(alast,b)
join(blast,a)

are linking node in each recursion call.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T00:52:44+00:00Added an answer on June 11, 2026 at 12:52 am

    I think you are over thinking this actually quite easy task – extracting the data from a binary tree in order is as simple as doing a depth first traversal – this is the point of a binary tree that it very efficiently gives you the elements in the sorted order.

    So what you need to do is a standard depth first walk of the tree and each time you find a node add it to you linked list.

    This in order depth first recursion is fairly straight forward is pseudocode:

    Traverse(Node N)
      Traverse(N.left);
      Add N to the linked list
      Traverse(N.right);
    

    I suggest you try this manually on you example so you see how it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have meet the error mentioned in the title, here is the code in
Pretty much what I have mentioned in the title. I am using CanCan::Ability in
As I have mentioned in the title, my dispatch_async is firing 10 times. And
As the title mentioned, I want to encode a Image Obj into some kind
I'm using jEdit 4.3 pre 16. As I've mentioned on the title, when I'm
same as in title? I have a test server with mentioned OS and my
As mentioned in title, I want to find out if there is really some
Is it possible what I have mentioned in the title? I would like to
I am new to script writing. I have encountered the mentioned in the title
As mentioned in the title, I want to find the pairs of elements whose

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.