How many different binary trees and binary search trees can
be made from three nodes that contain the key values 1, 2 & 3?

Answer Posted / shweta

for no. of different binary tree---
for n nodes the formula is 2^n-n in this formula value of
nodes are not considered, only the way nodes can be present
in a tree so for 3 nodes there can be 5 ways, for each way
no. of possibilty of values is 3! so answer comes out to be
5*6=30

1 1 1 1 1
A A A A A
2 3 2 2 2 2

A A A A
3 3 3 3

for binary search tree answer is 3

Is This Answer Correct ?    19 Yes 42 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How will you check the validity of an expression containing nested parentheses?

543


What are the different types of data structures?

531


How do you clear a stack?

526


What is data structure and its classification?

494


Name few concurrent collection classes?

490






What is sorting an array?

500


What are the types of bulleted list?

449


What is the best time complexity of bubble sort?

524


How to traverse data in a linked list in forward and backward direction, write the algorithm?

534


How does arraylist size work?

472


How to find if linked list has loop?

662


Can we use Generics with the array?

593


Can a tree be empty?

488


Is treemap thread safe?

515


Why do we need a data structure?

488