東京大学 情報理工学系研究科 コンピュータ科学専攻 2021年2月実施 問題1
Author
zephyr
Description
Ordered binary trees are trees in which each node has at most two ordered children. Below, Tn denotes the set of all the ordered binary trees with n leaves. Let dT(v) denote the depth of node v in an ordered binary tree T, i.e., the number of edges on the path from the root to v.
For a sequence P=(c1,c2,…,cn) of n positive real numbers, we define SP and HP by:
SP=i=1∑nci,HP=−i=1∑n(ci⋅log2(ci/SP)).
For an ordered binary tree T∈Tn, we define WP(T) by:
WP(T)=i=1∑n(ci⋅dT(vi)),
where vi is the i-th leaf from left in T.
Answer the following questions.
(1) Give the tree T∈T4 that has the smallest value of WP(T) in case P=(4,2,1,1).
(2) Show that ∑i=1n2−dT(vi)≤1 holds for any ordered binary tree T∈Tn with leaves v1,v2,…,vn.
(3) Assume that x1,x2,…,xn range over the set of positive real numbers so that ∑i=1nxi=1. Show that ∑i=1n(ci⋅log2xi) is maximized when xi=ci/SP for any sequence P=(c1,c2,…,cn) of n positive real numbers.
(4) Show that any ordered binary tree T∈Tn satisfies WP(T)≥HP for any sequence P=(c1,c2,…,cn) of n positive real numbers.
有序二叉树是指每个节点最多有两个有序子节点的树。下面,Tn 表示具有 n 叶节点的所有有序二叉树的集合。设 dT(v) 表示有序二叉树 T 中节点 v 的深度,即从根到 v 的路径上的边数。
对于一个由 n 个正实数组成的序列 P=(c1,c2,…,cn),我们定义 SP 和 HP 如下:
SP=i=1∑nci,HP=−i=1∑n(ci⋅log2(ci/SP)).
对于一个有序二叉树 T∈Tn,我们定义 WP(T) 如下:
WP(T)=i=1∑n(ci⋅dT(vi)),
其中 vi 是 T 中从左数的第 i 个叶节点。
回答以下问题。
(1) 给出在 P=(4,2,1,1) 情况下 T4 中 WP(T) 最小的树 T。
(2) 证明对于任何有叶节点 v1,v2,…,vn 的有序二叉树 T∈Tn,∑i=1n2−dT(vi)≤1 成立。
(3) 假设 x1,x2,…,xn 在正实数范围内变化,并且满足 ∑i=1nxi=1。证明对于任何由 n 个正实数组成的序列 P=(c1,c2,…,cn),当 xi=ci/SP 时,∑i=1n(ci⋅log2xi) 取得最大值。
(4) 证明对于任何有序二叉树 T∈Tn,对于任何由 n 个正实数组成的序列 P=(c1,c2,…,cn),WP(T)≥HP。
题目描述
有序二叉树的每个结点至多有两个有次序的子结点。记 Tn 为具有
n 个叶结点的所有有序二叉树的集合,dT(v) 为结点 v 在树 T 中的深度,即根到
v 的路径所含边数。对 n 个正数组成的序列
P=(c1,…,cn),定义
SP=i=1∑nci,HP=−i=1∑ncilog2(ci/SP).
对 T∈Tn,若 vi 是从左到右第 i 个叶结点,定义
WP(T)=i=1∑ncidT(vi).
回答下列问题。
(1)当 P=(4,2,1,1) 时,给出使 WP(T) 最小的
T∈T4。
(2)证明对任意具有叶结点 v1,…,vn 的
T∈Tn,
i=1∑n2−dT(vi)≤1.
(3)令正数 x1,…,xn 满足 ∑ixi=1。证明对任意正数序列
P=(c1,…,cn),当 xi=ci/SP 时,
i=1∑ncilog2xi
达到最大值。
(4)证明对任意正数序列 P 和任意 T∈Tn,
WP(T)≥HP。
- 最优字母序二叉树:在叶子次序固定时比较不同树形的加权外部路径长度。
- 二叉树的 Kraft 不等式:由叶深对应的二进制区间或归纳法证明码长和不超过一。
- 对数函数的约束优化:利用拉格朗日乘子或 KL 散度确定加权对数和的最大点。
- 熵下界:把 Kraft 不等式与最优化结论结合,证明加权路径长度不低于熵型量 HP。
Kai
(1)
To minimize WP(T), we should construct a tree that resembles a Huffman tree, where the most frequent items (with the highest weights) are located at shallower depths. Here, the weights are (4,2,1,1).
Steps to construct the tree:
- Start by pairing the two smallest weights, which are both 1.
- Combine these to form a subtree with a combined weight of 2.
- Now, we have weights (4,2,2).
- Next, combine the two smallest remaining weights, which are both 2.
- Combine these to form a subtree with a combined weight of 4.
- Finally, combine the two subtrees (4,4) to form the complete tree.
The resulting tree structure is:
O
/ \
4 O
/ \
2 O
/ \
1 1
Thus, the depth of each leaf in the tree is:
- c1=4, depth dT(v1)=1
- c2=2, depth dT(v2)=2
- c3=1, depth dT(v3)=3
- c4=1, depth dT(v4)=3
Now, we calculate WP(T):
WP(T)=4⋅1+2⋅2+1⋅3+1⋅3=4+4+3+3=14
Thus, the tree T that minimizes WP(T) has the above structure.
(2)
To prove the inequality ∑i=1n2−dT(vi)≤1 using mathematical induction, we need to follow these steps:
- Base Case
- Inductive Step
Base Case: For n=1 (a tree with only one leaf), the depth of the only leaf v1 is 0.
i=1∑12−dT(vi)=2−dT(v1)=20=1
Thus, the base case holds.
Inductive Step: Assume that for any ordered binary tree with k leaves, the inequality holds:
i=1∑k2−dT(vi)≤1
Now, we need to prove that the inequality holds for an ordered binary tree with k+1 leaves.
- Consider an ordered binary tree with k+1 leaves.
- Let's denote the depth of the leaves in this tree by dT(v1),dT(v2),…,dT(vk+1).
When we add an additional leaf to a tree with k leaves to form a tree with k+1 leaves, we must split one of the existing leaves into two children. This operation increases the depth of the affected leaf by 1 and adds a new leaf with the same depth.
Suppose we split the leaf vj (where dT(vj)=d) into two new leaves vj′ and vk+1, both at depth d+1.
Thus, we need to show:
i=1∑k2−dT(vi)+2−(d+1)+2−(d+1)≤1
By the inductive hypothesis, for the original tree with k leaves:
i=1∑k2−dT(vi)≤1
In the new tree:
i=1∑k2−dT(vi)−2−d+2−(d+1)+2−(d+1)
Since 2−(d+1)+2−(d+1)=2−d:
i=1∑k+12−dT(vi)=i=1∑k2−dT(vi)≤1
Thus, the inequality holds after adding a new leaf and increasing the depth of the original leaf.
By induction, the inequality ∑i=1n2−dT(vi)≤1 holds for all n.
(3)
To maximize ∑i=1n(ci⋅log2xi) under the constraint ∑i=1nxi=1, we use the method of Lagrange multipliers.
Define the Lagrangian:
L(x1,…,xn,λ)=i=1∑n(ci⋅log2xi)+λ(1−i=1∑nxi)
Take the partial derivatives and set them to zero:
∂xi∂L=xiln2ci−λ=0⇒xi=λln2ci
Using the constraint ∑i=1nxi=1:
i=1∑nλln2ci=1⇒λln2=SP⇒λ=ln2SP
Thus, the maximizing xi is:
xi=SPci
(4)
To show that WP(T)≥HP, we need to use the definitions of WP(T) and HP and employ some fundamental principles of information theory and entropy.
Recall:
WP(T)=i=1∑n(ci⋅dT(vi))
HP=−i=1∑n(ci⋅log2(SPci))
We start by rewriting HP in a more convenient form:
HP=i=1∑nci⋅(log2(SP)−log2(ci))=log2(SP)⋅i=1∑nci−i=1∑n(ci⋅log2(ci))
Since ∑i=1nci=SP, we get:
HP=SP⋅log2(SP)−i=1∑n(ci⋅log2(ci))
Next, consider the following inequality derived from Jensen's inequality for the concave function f(x)=−xlog2(x):
−i=1∑nSPci⋅log2(SPci)≤−log2(i=1∑nSPci⋅SPci)
This simplifies to:
−i=1∑nSPci⋅log2(SPci)≤−log2(i=1∑nSP2ci2)
Since ∑i=1nci=SP, we get:
−i=1∑nSPci⋅log2(SPci)≤−log2(SP21i=1∑nci2)
So:
−i=1∑nSPci⋅log2(SPci)≤−log2(SP21⋅SP⋅n1i=1∑nci)=log2(SP)
The weighted path length WP(T) can be understood using Kraft's inequality, which relates the depths of leaves in a binary tree to probabilities that sum up to 1. Let pi=SPci be the probability associated with the i-th leaf. According to Kraft's inequality:
i=1∑n2−dT(vi)≤1
We multiply both sides by SP:
SPi=1∑npi⋅2−dT(vi)≤SP
Using the fact that pi=SPci:
i=1∑nci⋅2−dT(vi)≤SP
Now, we apply the definition of entropy:
HP=−SPi=1∑npilog2(pi)
Using Gibbs' inequality, we know that:
−i=1∑npilog2(pi)≤i=1∑npidT(vi)
Multiplying both sides by SP:
SP⋅HP≤SPi=1∑npi⋅dT(vi)
Substituting pi=SPci into the inequality:
HP≤i=1∑nci⋅dT(vi)
Thus, we have shown that WP(T)≥HP for any ordered binary tree T∈Tn and any sequence P=(c1,c2,…,cn) of n positive real numbers.
Knowledge
有序二叉树 哈夫曼树 信息论 拉格朗日乘数法 数学归纳法
重点词汇
- Ordered binary tree 有序二叉树
- Huffman tree 哈夫曼树
- Depth 深度
- Lagrange multipliers 拉格朗日乘子
- Entropy 熵
- Lagrange multiplier 拉格朗日乘数
- Jensen's inequality 詹森不等式
- Gibbs' inequality 吉布斯不等式
- Kraft's inequality 克拉夫特不等式
参考资料
- Introduction to Algorithms, Chapter 16: Greedy Algorithms
- Information Theory, Inference, and Learning Algorithms, David J.C. MacKay