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 ? | 149 Yes | 22 No |
Post New Answer View All Answers
Describe linear probing with an example.
Define a path in a tree?
Explain what is the data structures used to perform recursion?
What is the difference between array and list?
How do you find the size of an arraylist?
What is storage structure in data structure?
What is the difference between Array and Arraylist?
Is arraylist a list?
Does hashmap maintain insertion order?
Why is hashmap faster than arraylist?
Can treemap key null?
What is the difference between push and pop?
Is array size dynamic or fixed?
Is array immutable?
Can arraylist hold different types?