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

How do treesets work internally?

485


What does isempty() member method determines?

545


Explain the Complete structure of hashmap along with the basic coding of the hashmap internal implementation.

591


Why use a tuple instead of a list?

451


What is ascii sort order?

457






What is collision in data structure?

496


What is hashing technique? Describe in brief.

516


Define collision in hashing?

488


How is the front of the queue calculated ?

710


Is array static or dynamic?

467


What are different types of sorting techniques?

509


How many types of searching are there in data structure?

423


How do you find the time complexity of a bubble sort?

478


What is a stable algorithm?

469


What is a matrix?

542