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 8308091
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:41:33+00:00 2026-06-08T18:41:33+00:00

Consider I have an array [3,18,15,25,26] , how many possible binary search trees can

  • 0

Consider I have an array [3,18,15,25,26], how many possible binary search trees can be formed from it?

  • 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-08T18:41:34+00:00Added an answer on June 8, 2026 at 6:41 pm

    After looking at the question linked by MicSim, I still wasn’t satisfied with that, so I began looking at it myself. Here’s what I came up with…

    Each tree can be thought of as two trees with a parent root node. If you know the number of possible combinations of the two children branches separately, the total combinations having that root node is the product of the children combinations.

    We can begin building up a higher count solution by solving the lower count instances first.

    I will use C(n) to represent the total possible combinations of n nodes, the Catalan Number.

    Hopefully these two are obvious:

    C(0) = 1
    C(1) = 1
    

    C(2) is also fairly obvious, but it can be built, so let’s do that. There are two ways to choose the root node. One leaves a child count (left:right) of 1:0 and the other 0:1. So, the first possibility is C(1)*C(0) = 1*1 = 1. And the second is C(0)*C(1) = 1*1 = 1. Summing those together gives us

    C(2) = 2
    

    Nothing too exciting yet. Now let’s do 3 nodes. There are 3 ways to choose the root node and, hence, 3 child groupings. Your possible groups are 2:0, 1:1 and 0:2.

    Based on our prior defintions, C(3) can be written as C(2)*C(0) + C(1)*C(1) + C(0)*C(2) = 2*1 + 1*1 + 1*2 = 2+1+2 = 5.

    C(3) = 5
    

    4 nodes has child groupings of 3:0, 2:1, 1:2 and 0:3. So, C(4) can be written as C(3)*C(0) + C(2)*C(1) + C(1)*C(2) + C(0)*C(3) = 5*1 + 2*1 + 1*2 + 1*5 = 5+2+2+5 = 14.

    C(4) = 14
    

    Hopefully, two things are beginning to become apparent. First, this will start becoming cumbersome fairly soon. Second, that what I have described, in a fairly long-winded fashion, is the recurrence relation representation on the wiki page.

    I don’t know if this helps, but it helped me to go through the exercise, so I thought I’d share. I wasn’t trying to recreate the recurrence relation when I started, so it was good that my results matched one of the existing methods.

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

Sidebar

Related Questions

Assume that we have multiple arrays of integers. You can consider each array as
Consider I have an array of hashes (which is my map/reduced output from MongoDB)
Consider I have an array of elements out of which I want to create
I know the question sounds silly, but consider this: I have an array of
Consider I have two arrays: $friends = Array('foo', 'bar', 'alpha'); $attendees = Array('foo', 'bar');
Consider the following scenario . I have an array of numbers: [ 1,2,3,4 ]
Consider an array of Tags, T. Each PhotoSet has a many-to-many relationship to Tags.
I have an application where users can register themselves using Facebook credentials. Now consider
I have an array a of 10 booleans (or equivalently the binary representation of
I have to sort an array. Apart from the already existing types of sorting

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.