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
Differentiate between iterable and iterator.
Define splay tree?
Can arraylist store primitives?
How is the front of the queue calculated in data structure?
Can we change load factor of hashmap?
Traverse the given tree using Inorder, Preorder and Postorder traversals. Inorder : D H B E A F C I G J Preorder: A B D H E C F G I J Postorder: H D E B F I J G C A
What is a simple path?
What is selection in an algorithm?
How to reverse singly link list?
Give one example of right rotation.
how to display Singly Linked List from First to Last?
Which is faster arraylist or linked list?
What is sorting with example?
What is mean by selection sort?
Write a Program for Insert in a sorted list