Yes. So.... what are the valid binary search trees?Hi,
I got your point. This does not satisfy bst property. The entire left subtree should be less than 2. Same is true with #4.
This would further reduce the number of binary search trees.
Zulfi.
Do you mean?Well, I can root the top level node in any one of the 5 distinct values, placing all values less that the root in the left subtree and all the values larger than the root in the right subtree. So the number of nodes in each subtree are:
No. Consider the following tree (and I REALLY wish you would start using a reasonable depiction of a tree).Do you mean?
Left Subtree Right Sub Tree
0, 4 (0 as the root)
1, 3 (1 as the root)
2, 2 (2 as the root)
3, 1 (3 as the root)
4, 0 (4 as the root)
Exactly what I stated: "T(N) is the number of BSTs that can be made with N distinct nodes"What do you mean by T(2)?
I understand this but i cant understand this:3 is the root of the tree. The left subtree consists of {1,2} and the right subtree consists of {4,5}.
Which node is used as root above?0,4
1,3
2,2,
3,1
4,0
for which bst's are:T(3) = T(2)*T(0) + T(1)*T(1) + T(0)*T(2)
Thanks for your time.BST are :
1 (root)
2 (R)
3(R)
----------
2:
1(root)
3(R)
2(L)
----------
3:
3(root)
2(L)
1(L)
----------------------
4:
3(root)
1(L)
2(R)
---------------
5:
2 (root)
1(L) 3 (R)
Hi,
Thanks for teaching me all this. I would take some time.
Zulfi.
Boy, you weren't kidding when you said you would take some time!Hi,
Thanks again. I tried and I am able to understand this but for clear understanding i have to solve this whole thing on my own. I would try and if got problem i would let you know.
Zulfi.
Thread starter | Similar threads | Forum | Replies | Date |
---|---|---|---|---|
Z | Binary Search Understanding & Running Time calculation line by line | Homework Help | 13 | |
Z | Search a Binary Search Tree | Homework Help | 8 | |
Z | Nummber of Comparisons in Binary Search (worst Case) | Homework Help | 3 | |
C | Binary search Matlab | Programming & Languages | 0 | |
C | Binary search | Programming & Languages | 2 |