38 38 votes How many distinct BSTs can be constructed with $3$ distinct keys? $4$ $5$ $6$ $9$ Data Structures gateit-2008 data-structures binary-search-tree normal + – Ishrat Jahan 19.1k views answer comment Share Follow Print See all 13 Comments 13 13 Comments reply Show 10 previous comments Rohit ._. commented Nov 13, 2025 reply Follow flag @Shaik Masthan Sir in below question we are not trying to change the structure of the binary tree so 1 BST is possible right. I found this and below question related so asked.https://gateoverflow.in/2131/gate-cse-2011-question-29#a_list 0 0 replyShare Shaik Masthan commented Nov 13, 2025 reply Follow flag @Rohit Pol,Yes. We are not allowed to change the structure of binary tree. We may change the numbers inside that. But to make it BST, we have only one sequence. 2 2 replyShare Rohit ._. commented Nov 13, 2025 reply Follow flag Understood sir! 0 0 replyShare Please log in or register to add a comment.
Best answer 54 54 votes For number of distinct BSTs with $n$ nodes we apply the formula $\dfrac{C(2n,n) }{n+1}$ $n=3$ here, so $C(6,3)=20$ So, $\frac{C(2n,n)}{n+1} =20/4=5$ Answer is $\mathbf{5}$ REF :- https://gatecse.in/number-of-binary-trees-possible-with-n-nodes/ Correct Answer: $B$ Abhimanyu Kumar answered Nov 20, 2014 • edited May 4, 2019 by Naveen Kumar 3 Abhimanyu Kumar comment Share Follow See all 6 Comments 6 6 Comments reply Show 3 previous comments PratikDey0316 commented Dec 2, 2020 reply Follow flag https://gateoverflow.in/485/gate2008-62 Why can’t we solve this question in a similar way as it is solved in the above link? 0 0 replyShare Manavsinh_Mori commented Aug 13, 2025 reply Follow flag 2n!/(n-1)1n!why thorugh this formula this question can't be solved.? 1 1 replyShare tarentula commented Aug 14 reply Follow flag @Manavsinh_Mori It can be solved mate. 0 0 replyShare Please log in or register to add a comment.
2 2 votes Option B is the answer Vasudevarnab_das answered Mar 18, 2023 Vasudevarnab_das comment Share Follow 0 reply Please log in or register to add a comment.
1 1 vote Option B) 5 is Correct answerLet's solve this using Catalan number :$$C_n = \frac{(2n)!}{(n+1)! n!}$$here n = no. of distinct keys ; n = 3 (given in question) $$C_n = \frac{(2n)!}{(n+1)! n!}$$ $$ = \frac{(2 * 3)!}{(3+1)! 3!}$$ $$ = \frac{6!}{4! * 3!}$$ $$ = \frac{6 * 5 }{6}$$ $$ = 5 $$ Umesh Shelke answered Aug 29, 2025 Umesh Shelke comment Share Follow 0 reply Please log in or register to add a comment.
0 0 votes We can solve this using the concept of Catalan Number. They given 3 distinct key. Then, 1/n+1*(2nCn) , n=3 =1/4*6c3 1/4 *20 =5 (Option B) Then ans is 5 Hazard answered Mar 10, 2025 Hazard comment Share Follow 0 reply Please log in or register to add a comment.