In this posted question Fig. 15.9 (b) is considered the optimal tree with expected search cost of 2.75 but by swapping the k_3 subtree with leaf d_0 we can get an expected search cost of 2.65, is there something incorrect with my reasoning?
Asked
Active
Viewed 130 times
1 Answers
1
As you see in the book K = {k1; k2;:::;kn} of n distinct keys in sorted order (so that k1 < k2 < k3< k4 < k5)
Because both Fig. 15.9 (a) and Fig. 15.9 (b) are BST so they have the same order if you use preorder traversal: k1=>k2=>k3=>k4=>k5
By swapping the k_3 subtree with leaf d_0, the order will change if you use preorder traversal: k3=>k1=>k2=>k4=>k5

Hua Chi Quan
- 156
- 1
- 2
- 8
-
Did you mean inorder traversal? I see what you mean though. Thank you for your explanation. – Claska Feb 04 '21 at 10:21