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部分
- kr是root,depth为1,贡献pr
- 对于以ki ... kr-1构成的left subtree,ki ... kr-1这些节点以及叶子节点的depth都加1,根据公式15.11第一行,贡献e[i,r-1] + w(i,r-1)
- 对于以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的更多相关文章
- Optimal binary search trees
问题 该问题的实际应用 Suppose that we are designing a program to translate text from English to French. For ea ...
- Method for balancing binary search trees
Method for balancing a binary search tree. A computer implemented method for balancing a binary sear ...
- LeetCode解题报告—— Unique Binary Search Trees & Binary Tree Level Order Traversal & Binary Tree Zigzag Level Order Traversal
1. Unique Binary Search Trees Given n, how many structurally unique BST's (binary search trees) that ...
- 【二叉查找树】02不同的二叉查找树个数II【Unique Binary Search Trees II】
提到二叉查找树,就得想到二叉查找树的递归定义, 左子树的节点值都小于根节点,右子树的节点值都大于根节点. +++++++++++++++++++++++++++++++++++++++++++++++ ...
- 【二叉查找树】01不同的二叉查找树的个数【Unique Binary Search Trees】
当数组为1,2,3,4,...,n时,基于以下原则构建的BST树具有唯一性: 以i为根节点的树,其左子树由[1,i-1]构成,其右子树由[i+1, n]构成. 我们假定f(i)为以[1,i]能产生的U ...
- [LeetCode] Unique Binary Search Trees 独一无二的二叉搜索树
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
- [LeetCode] Unique Binary Search Trees II 独一无二的二叉搜索树之二
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...
- 2 Unique Binary Search Trees II_Leetcode
Given n, generate all structurally unique BST's (binary search trees) that store values 1...n. For e ...
- 【leetcode】Unique Binary Search Trees (#96)
Given n, how many structurally unique BST's (binary search trees) that store values 1...n? For examp ...
随机推荐
- excel怎么并排查看两个工作表
excel怎么并排查看两个工作表 excel怎么并排查看两个工作表?excel打开一个窗口想要同时查看两个工作表中的数据,类似于word中的分栏效果,该怎么实现呢?EXCEL是一个使用最多的办公软件, ...
- WPF:数据绑定总结(1) https://segmentfault.com/a/1190000012981745
WPF:数据绑定总结(1) visual-studio c# 1.3k 次阅读 · 读完需要 16 分钟 0 一.概念:什么是数据绑定? WPF中的数据绑定:是在应用程序 UI 与业务逻辑之间建立 ...
- 最短路 HDU - 2544 (dijkstra算法或Floyd算法)
Dijkstra解法: #include <stdio.h> #include <iostream> #include <cstring> #include < ...
- 【Pyqt5】自定义信号简单原理(易懂版),多窗口交互,传输数据,调用方法
PS:如果你想在2窗口调用1窗口的内部方法,或者在2窗口传递数据给1窗口数据,本片博客可以放心食用 主窗口: class MainWindow(QWidget,Ui_MainFrom): insert ...
- python3.7 安装gensim使用word2Vec库
应用的文章(个人试验过,完全正确):https://radimrehurek.com/gensim/index.html#install
- windows上安装Anaconda和python的教程详解
一提到数字图像处理编程,可能大多数人就会想到matlab,但matlab也有自身的缺点: 1.不开源,价格贵 2.软件容量大.一般3G以上,高版本甚至达5G以上. 3.只能做研究,不易转化成软件. 因 ...
- python mooc 3维可视化<第一周第一单元>
基本含义 数据->图像 分类 重点关注空间数据的可视化 方法 二维标量数据场 三维标量数据场 二位标量数据场 颜色映射法 等值线法 立体图法 层次分割法 三维标量数据场 面绘制法 体绘制法 展示 ...
- solr dataimport中遇到的问题
1.windows的tomcat是没有catalina.out的,可以通过修改start.bat和catalina.bat的方式让日志输出到catalina.out 2.按照网上搜到的资料配置好sol ...
- springboot security 安全
spring security几个概念 “认证”(Authentication) 是建立一个他声明的主体的过程(一个“主体”一般是指用户,设备或一些可以在你的应用程序中执行动作的其他系统) . “授权 ...
- 微信小程序组件——详解wx:if elif else的用法
背景 在学习微信小程序开发wxml页面时,需要使用if,else来判断组件是否进行展示,代码如下 <view wx:if="{{is_login==1}}">成功登录& ...