ITA 15.5 Optimal binary search trees

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ITA 15.5 Optimal binary search trees相关的知识,希望对你有一定的参考价值。

p400 页最后一段

When j >= i , we need to select a root kr from among ki ... kj and then make an optimal binary search tree with keys ki ... kr-1 as its left subtree and an optimal binary search tree with keys kr+1 ... kj as its right subtree.What happens to the expected search cost of a subtree when it becomes a subtree of a node? (这里的subtree指的是ki ... kr-1构成的left subtree或kr+1 ... kj构成的right subtree) The depth of each node in the subtree increases by 1. By equation (15.11), the expected search cost of this subtree increases by the sum of all the probabilities in the subtree.

在计算以kr为root的tree的E[search cost in T]的时候

E[search cost in T] = e[i, j],包括3部分

  1. kr是root,depth为1,贡献pr
  2. 对于以ki ... kr-1构成的left subtree,ki ... kr-1这些节点以及叶子节点的depth都加1,根据公式15.11第一行,贡献e[i,r-1] + w(i,r-1)
  3. 对于以kr+1 ... kj构成的right subtree,kr+1 ... kj这些节点以及叶子节点的depth都加1,根据公式15.11第一行,贡献e[r+1,j] + w(r+1,j)

所以

e[i,j] = pr + e[i,r-1] + w(i,r-1) + e[r+1,j] + w(r+1,j)

 

以上是关于ITA 15.5 Optimal binary search trees的主要内容,如果未能解决你的问题,请参考以下文章

UVA 10304 Optimal Binary Search Tree

Dynamic programming--optimal binary search tree

UVA10304 Optimal Binary Search Tree最优排序二叉树

uva 10304 - Optimal Binary Search Tree 区间dp

2018.3.5-6 knapsack problem, sequence alignment and optimal binary search trees

基于linux5.15.5的IMX 参考手册 --- 16