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
What is dynamic array how is it created?
List the limitations of linear probing?
Why do we use insertion sort?
Why do we need a data structure?
Does list allow null values?
Which sorting method is slowest?
Is arraylist a class?
Does arraylist maintain insertion order?
What are the parts of a linked list?
What are different techniques for making hash function?
How does hashset maintain order?
What is the difference between b tree and binary search tree?
Write a program for Sorting an Array. Which sorting will you prefer?
What are all the classes and interfaces that are available in the collections?
What are arrays used for?