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 / aisha

Binary tree :- 30 as follows

1 1 2 2 3 3
/ \ / \ / \ / \ / \ / \
2 3 3 2 1 3 3 1 1 2 2 1

1 1 1 1 1 1 1 1
/ / / / \ \ \ \
2 3 2 3 2 3 2 3
/ / \ \ / / \ \
3 2 3 2 3 2 3 2

2 2 2 2 2 2 2 2
/ / / / \ \ \ \
1 3 1 3 1 3 1 3
/ / \ \ / / \ \
3 1 3 1 3 1 3 1

3 3 3 3 3 3 3 3
/ / / / \ \ \ \
2 1 2 1 2 1 2 1
/ / \ \ / / \ \
1 2 1 2 1 2 1 2

Binary search tree :-5 as follows

1 1 2 3 3
\ \ / \ / /
2 3 1 3 1 2
\ / \ /
3 2 2 1

Is This Answer Correct ?    148 Yes 22 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is dynamic array how is it created?

453


List the limitations of linear probing?

522


Why do we use insertion sort?

474


Why do we need a data structure?

475


Does list allow null values?

476






Which sorting method is slowest?

524


Is arraylist a class?

453


Does arraylist maintain insertion order?

458


What are the parts of a linked list?

636


What are different techniques for making hash function?

481


How does hashset maintain order?

512


What is the difference between b tree and binary search tree?

474


Write a program for Sorting an Array. Which sorting will you prefer?

571


What are all the classes and interfaces that are available in the collections?

486


What are arrays used for?

527