Computer Science Engineering (CSE) Exam  >  Computer Science Engineering (CSE) Questions  >  How many distinct BSTs can be constructed wit... Start Learning for Free
How many distinct BSTs can be constructed with 3 distinct keys?
  • a)
    4
  • b)
    5
  • c)
    6
  • d)
    9
Correct answer is option 'B'. Can you explain this answer?
Most Upvoted Answer
How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c...
For distinct BST we apply this formula 

n = 3 here so C(6, 3) = 20 and 20/4 = 5
Free Test
Community Answer
How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c...
Explanation:
To construct distinct BSTs, we must have distinct keys. Let's consider three distinct keys: 1, 2, and 3.

Case 1: The root of the tree is 1.
In this case, the left subtree must be empty, so there is only one possible BST.

Case 2: The root of the tree is 2.
In this case, there are two possible BSTs:
- 2 is the root, 1 is the left child, and 3 is the right child.
- 2 is the root, 3 is the left child, and 1 is the right child.

Case 3: The root of the tree is 3.
In this case, the right subtree must be empty, so there is only one possible BST.

Therefore, the total number of distinct BSTs that can be constructed with three distinct keys is 1 + 2 + 1 = 4.

However, the question asks for the number of distinct BSTs that can be constructed with 3 distinct keys, which means we cannot have a BST with less than 3 nodes. Therefore, we need to consider the case where we have a root, a left child, and a right child.

Case 4: The root of the tree is 1.
In this case, the left subtree must be empty, so there is only one possible BST.

Case 5: The root of the tree is 2.
In this case, there are two possible BSTs:
- 2 is the root, 1 is the left child, and 3 is the right child.
- 2 is the root, 3 is the left child, and 1 is the right child.

Case 6: The root of the tree is 3.
In this case, there are two possible BSTs:
- 3 is the root, 1 is the left child, and 2 is the right child.
- 3 is the root, 2 is the left child, and 1 is the right child.

Therefore, the total number of distinct BSTs that can be constructed with three distinct keys is 1 + 2 + 2 = 5.

Therefore, option 'B' is the correct answer.
Explore Courses for Computer Science Engineering (CSE) exam
Question Description
How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer? for Computer Science Engineering (CSE) 2025 is part of Computer Science Engineering (CSE) preparation. The Question and answers have been prepared according to the Computer Science Engineering (CSE) exam syllabus. Information about How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer? covers all topics & solutions for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, meanings, examples, exercises and tests below for How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer?.
Solutions for How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer? in English & in Hindi are available as part of our courses for Computer Science Engineering (CSE). Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.
Here you can find the meaning of How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer? defined & explained in the simplest way possible. Besides giving the explanation of How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer?, a detailed solution for How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer? has been provided alongside types of How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer? theory, EduRev gives you an ample number of questions to practice How many distinct BSTs can be constructed with 3 distinct keys?a)4b)5c)6d)9Correct answer is option 'B'. Can you explain this answer? tests, examples and also practice Computer Science Engineering (CSE) tests.
Explore Courses for Computer Science Engineering (CSE) exam
Signup to solve all Doubts
Signup to see your scores go up within 7 days! Learn & Practice with 1000+ FREE Notes, Videos & Tests.
10M+ students study on EduRev