資料結構›Ch9 進階樹
第 79 題/共 88 題
◀ DS 79/88
79. Optimal Binary Search Tree、OBST
#DS-09-079中Optimal Binary Search TreeOBST

(10%) We are given a sequence K=⟨k1,k2,...,kn⟩K = \langle k_1, k_2, ..., k_n \rangle of nn distinct keys in sorted order (so that k1<k2<⋯<knk_1 < k_2 < \cdots < k_n), and we wish to build a binary search tree from these keys. For each key kik_i, we have a probability pip_i that a search will be for kik_i. Some searches may be for values not in KK, and so we also have n+1n+1 "dummy keys" d0,d1,…,dnd_0, d_1, \ldots, d_n representing values not in KK. In particular, d0d_0 represents all values less than k1k_1, dnd_n represents all values greater than knk_n, and for i=1,2,…,n−1i = 1, 2, \ldots, n-1, the dummy key did_i represents all values between kik_i and ki+1k_{i+1}. For each dummy key did_i, we have a probability qiq_i that a search will correspond to did_i. Determine the cost and structure of an optimal binary search tree in the expected cost of search time for a set of n=7n = 7 keys with the following probabilities:

ii01234567
pip_i0.040.060.080.020.100.120.14
qiq_i0.060.060.060.060.050.050.050.05
📄 成大112
跳轉到第題
▤完整推導請見《WH 資工筆記 · 資料結構》Ch9 進階樹
本章題號 · 61–80 / 88