資料結構›Ch9 進階樹第 79 題/共 88 題
79. Optimal Binary Search Tree、OBST
#DS-09-079中Optimal Binary Search TreeOBST
(10%) We are given a sequence of distinct keys in sorted order (so that ), and we wish to build a binary search tree from these keys. For each key , we have a probability that a search will be for . Some searches may be for values not in , and so we also have "dummy keys" representing values not in . In particular, represents all values less than , represents all values greater than , and for , the dummy key represents all values between and . For each dummy key , we have a probability that a search will correspond to . Determine the cost and structure of an optimal binary search tree in the expected cost of search time for a set of keys with the following probabilities:
| 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | |
|---|---|---|---|---|---|---|---|---|
| 0.04 | 0.06 | 0.08 | 0.02 | 0.10 | 0.12 | 0.14 | ||
| 0.06 | 0.06 | 0.06 | 0.06 | 0.05 | 0.05 | 0.05 | 0.05 |
📄 成大112
▤完整推導請見《WH 資工筆記 · 資料結構》Ch9 進階樹