跳到主要内容

東京大学 情報理工学系研究科 コンピュータ科学専攻 2021年2月実施 問題1

Author

zephyr, 祭音Myyura

Description

Ordered binary trees are trees in which each node has at most two ordered children. Below, Tn\mathbf{T_n} denotes the set of all the ordered binary trees with nn leaves. Let dT(v)\mathrm{d_T}(v) denote the depth of node vv in an ordered binary tree TT, i.e., the number of edges on the path from the root to vv.

For a sequence P=(c1,c2,,cn)\mathbf{P} = (c_1, c_2, \ldots, c_n) of nn positive real numbers, we define SP\mathbf{S_P} and HP\mathbf{H_P} by:

SP=i=1nci,HP=i=1n(cilog2(ci/SP)).\mathbf{S_P} = \sum_{i=1}^{n} c_i, \quad \mathbf{H_P} = - \sum_{i=1}^{n} (c_i \cdot \log_2(c_i/\mathbf{S_P})).

For an ordered binary tree TTnT \in \mathbf{T_n}, we define WP(T)\mathbf{W_P}(T) by:

WP(T)=i=1n(cidT(vi)),\mathbf{W_P}(T) = \sum_{i=1}^{n} (c_i \cdot \mathrm{d_T}(v_i)),

where viv_i is the ii-th leaf from left in TT.

Answer the following questions.

(1) Give the tree TT4T \in \mathbf{T_4} that has the smallest value of WP(T)\mathbf{W_P}(T) in case P=(4,2,1,1)\mathbf{P} = (4, 2, 1, 1).

(2) Show that i=1n2dT(vi)1\sum_{i=1}^{n} 2^{-\mathrm{d_T}(v_i)} \leq 1 holds for any ordered binary tree TTnT \in \mathbf{T_n} with leaves v1,v2,,vnv_1, v_2, \ldots, v_n.

(3) Assume that x1,x2,,xnx_1, x_2, \ldots, x_n range over the set of positive real numbers so that i=1nxi=1\sum_{i=1}^{n} x_i = 1. Show that i=1n(cilog2xi)\sum_{i=1}^{n} (c_i \cdot \log_2 x_i) is maximized when xi=ci/SPx_i = c_i/\mathbf{S_P} for any sequence P=(c1,c2,,cn)\mathbf{P} = (c_1, c_2, \ldots, c_n) of nn positive real numbers.

(4) Show that any ordered binary tree TTnT \in \mathbf{T_n} satisfies WP(T)HP\mathbf{W_P}(T) \geq \mathbf{H_P} for any sequence P=(c1,c2,,cn)\mathbf{P} = (c_1, c_2, \ldots, c_n) of nn positive real numbers.


有序二叉树是指每个节点最多有两个有序子节点的树。下面,Tn\mathbf{T_n} 表示具有 nn 叶节点的所有有序二叉树的集合。设 dT(v)\mathrm{d_T}(v) 表示有序二叉树 TT 中节点 vv 的深度,即从根到 vv 的路径上的边数。

对于一个由 nn 个正实数组成的序列 P=(c1,c2,,cn)\mathbf{P} = (c_1, c_2, \ldots, c_n),我们定义 SP\mathbf{S_P}HP\mathbf{H_P} 如下:

SP=i=1nci,HP=i=1n(cilog2(ci/SP)).\mathbf{S_P} = \sum_{i=1}^{n} c_i, \quad \mathbf{H_P} = - \sum_{i=1}^{n} (c_i \cdot \log_2(c_i/\mathbf{S_P})).

对于一个有序二叉树 TTnT \in \mathbf{T_n},我们定义 WP(T)\mathbf{W_P}(T) 如下:

WP(T)=i=1n(cidT(vi)),\mathbf{W_P}(T) = \sum_{i=1}^{n} (c_i \cdot \mathrm{d_T}(v_i)),

其中 viv_iTT 中从左数的第 ii 个叶节点。

回答以下问题。

(1) 给出在 P=(4,2,1,1)\mathbf{P} = (4, 2, 1, 1) 情况下 T4\mathbf{T_4}WP(T)\mathbf{W_P}(T) 最小的树 TT

(2) 证明对于任何有叶节点 v1,v2,,vnv_1, v_2, \ldots, v_n 的有序二叉树 TTnT \in \mathbf{T_n}i=1n2dT(vi)1\sum_{i=1}^{n} 2^{-\mathrm{d_T}(v_i)} \leq 1 成立。

(3) 假设 x1,x2,,xnx_1, x_2, \ldots, x_n 在正实数范围内变化,并且满足 i=1nxi=1\sum_{i=1}^{n} x_i = 1。证明对于任何由 nn 个正实数组成的序列 P=(c1,c2,,cn)\mathbf{P} = (c_1, c_2, \ldots, c_n),当 xi=ci/SPx_i = c_i/\mathbf{S_P} 时,i=1n(cilog2xi)\sum_{i=1}^{n} (c_i \cdot \log_2 x_i) 取得最大值。

(4) 证明对于任何有序二叉树 TTnT \in \mathbf{T_n},对于任何由 nn 个正实数组成的序列 P=(c1,c2,,cn)\mathbf{P} = (c_1, c_2, \ldots, c_n)WP(T)HP\mathbf{W_P}(T) \geq \mathbf{H_P}

题目描述

有序二叉树的每个结点至多有两个有次序的子结点。记 TnT_n 为具有 nn 个叶结点的所有有序二叉树的集合,dT(v)d_T(v) 为结点 vv 在树 TT 中的深度,即根到 vv 的路径所含边数。对 nn 个正数组成的序列 P=(c1,,cn)P=(c_1,\ldots,c_n),定义

SP=i=1nci,HP=i=1ncilog2(ci/SP).S_P=\sum_{i=1}^n c_i,\qquad H_P=-\sum_{i=1}^n c_i\log_2(c_i/S_P).

TTnT\in T_n,若 viv_i 是从左到右第 ii 个叶结点,定义

WP(T)=i=1ncidT(vi).W_P(T)=\sum_{i=1}^n c_i\,d_T(v_i).

回答下列问题。

(1)当 P=(4,2,1,1)P=(4,2,1,1) 时,给出使 WP(T)W_P(T) 最小的 TT4T\in T_4

(2)证明对任意具有叶结点 v1,,vnv_1,\ldots,v_nTTnT\in T_n

i=1n2dT(vi)1.\sum_{i=1}^n2^{-d_T(v_i)}\le1.

(3)令正数 x1,,xnx_1,\ldots,x_n 满足 ixi=1\sum_i x_i=1。证明对任意正数序列 P=(c1,,cn)P=(c_1,\ldots,c_n),当 xi=ci/SPx_i=c_i/S_P 时,

i=1ncilog2xi\sum_{i=1}^n c_i\log_2x_i

达到最大值。

(4)证明对任意正数序列 PP 和任意 TTnT\in T_nWP(T)HPW_P(T)\ge H_P

Kai

(1)

To minimize WP(T)\mathbf{W_P}(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)(4, 2, 1, 1).

Steps to construct the tree:

  1. Start by pairing the two smallest weights, which are both 11.
  2. Combine these to form a subtree with a combined weight of 22.
  3. Now, we have weights (4,2,2)(4, 2, 2).
  4. Next, combine the two smallest remaining weights, which are both 22.
  5. Combine these to form a subtree with a combined weight of 44.
  6. Finally, combine the two subtrees (4,4)(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=4c_1 = 4, depth dT(v1)=1\mathrm{d_T}(v_1) = 1
  • c2=2c_2 = 2, depth dT(v2)=2\mathrm{d_T}(v_2) = 2
  • c3=1c_3 = 1, depth dT(v3)=3\mathrm{d_T}(v_3) = 3
  • c4=1c_4 = 1, depth dT(v4)=3\mathrm{d_T}(v_4) = 3

Now, we calculate WP(T)\mathbf{W_P}(T):

WP(T)=41+22+13+13=4+4+3+3=14\mathbf{W_P}(T) = 4 \cdot 1 + 2 \cdot 2 + 1 \cdot 3 + 1 \cdot 3 = 4 + 4 + 3 + 3 = 14

Thus, the tree TT that minimizes WP(T)\mathbf{W_P}(T) has the above structure.

(2)

To prove the inequality i=1n2dT(vi)1\sum_{i=1}^{n} 2^{-\mathrm{d_T}(v_i)} \leq 1 using mathematical induction, we need to follow these steps:

  1. Base Case
  2. Inductive Step

First contract every node having exactly one child. This only decreases the depths of its descendant leaves, so it can only increase the sum. It therefore suffices to prove the result for full ordered binary trees, in which every internal node has two children.

Base Case: For n=1n = 1 (a tree with only one leaf), the depth of the only leaf v1v_1 is 0.

i=112dT(vi)=2dT(v1)=20=1\sum_{i=1}^{1} 2^{-\mathrm{d_T}(v_i)} = 2^{-\mathrm{d_T}(v_1)} = 2^0 = 1

Thus, the base case holds.

Inductive Step: Assume that for any full ordered binary tree with kk leaves, the inequality holds:

i=1k2dT(vi)1\sum_{i=1}^{k} 2^{-\mathrm{d_T}(v_i)} \leq 1

Now, we need to prove that the inequality holds for a full ordered binary tree with k+1k+1 leaves.

  1. Consider a full ordered binary tree with k+1k+1 leaves.
  2. Let's denote the depth of the leaves in this tree by dT(v1),dT(v2),,dT(vk+1)\mathrm{d_T}(v_1), \mathrm{d_T}(v_2), \ldots, \mathrm{d_T}(v_{k+1}).

Every full tree with k+1k+1 leaves contains two sibling leaves. Contracting such a pair produces a full tree with kk leaves; conversely, the original tree is obtained by splitting that contracted leaf into two children.

Suppose we split the leaf vjv_j (where dT(vj)=d\mathrm{d_T}(v_j) = d) into two new leaves vjv_j' and vk+1v_{k+1}, both at depth d+1d+1.

Thus, we need to show:

i=1k2dT(vi)2d+2(d+1)+2(d+1)1\sum_{i=1}^{k} 2^{-\mathrm{d_T}(v_i)}-2^{-d} + 2^{-(d+1)} + 2^{-(d+1)} \leq 1

By the inductive hypothesis, for the original tree with kk leaves:

i=1k2dT(vi)1\sum_{i=1}^{k} 2^{-\mathrm{d_T}(v_i)} \leq 1

In the new tree:

i=1k2dT(vi)2d+2(d+1)+2(d+1)\sum_{i=1}^{k} 2^{-\mathrm{d_T}(v_i)} - 2^{-d} + 2^{-(d+1)} + 2^{-(d+1)}

Since 2(d+1)+2(d+1)=2d2^{-(d+1)} + 2^{-(d+1)} = 2^{-d}:

i=1k+12dT(vi)=i=1k2dT(vi)1\sum_{i=1}^{k+1} 2^{-\mathrm{d_T}(v_i)} = \sum_{i=1}^{k} 2^{-\mathrm{d_T}(v_i)} \leq 1

Thus, the inequality holds after adding a new leaf and increasing the depth of the original leaf.

By induction, the inequality i=1n2dT(vi)1\sum_{i=1}^{n} 2^{-\mathrm{d_T}(v_i)} \leq 1 holds for all nn.

(3)

To maximize i=1n(cilog2xi)\sum_{i=1}^{n} (c_i \cdot \log_2 x_i) under the constraint i=1nxi=1\sum_{i=1}^{n} x_i = 1, we use the method of Lagrange multipliers.

Define the Lagrangian:

L(x1,,xn,λ)=i=1n(cilog2xi)+λ(1i=1nxi)\mathcal{L}(x_1, \ldots, x_n, \lambda) = \sum_{i=1}^{n} (c_i \cdot \log_2 x_i) + \lambda \left( 1 - \sum_{i=1}^{n} x_i \right)

Take the partial derivatives and set them to zero:

Lxi=cixiln2λ=0xi=ciλln2\frac{\partial \mathcal{L}}{\partial x_i} = \frac{c_i}{x_i \ln 2} - \lambda = 0 \quad \Rightarrow \quad x_i = \frac{c_i}{\lambda \ln 2}

Using the constraint i=1nxi=1\sum_{i=1}^{n} x_i = 1:

i=1nciλln2=1λln2=SPλ=SPln2\sum_{i=1}^{n} \frac{c_i}{\lambda \ln 2} = 1 \quad \Rightarrow \quad \lambda \ln 2 = \mathbf{S_P} \quad \Rightarrow \quad \lambda = \frac{\mathbf{S_P}}{\ln 2}

Thus, the maximizing xix_i is:

xi=ciSPx_i = \frac{c_i}{\mathbf{S_P}}

Moreover, 2L/xi2=ci/(xi2ln2)<0\partial^2\mathcal L/\partial x_i^2=-c_i/(x_i^2\ln 2)<0. Hence the objective is strictly concave on the constraint set, so this stationary point is the unique global maximum.

(4)

To show that WP(T)HP\mathbf{W_P}(T) \geq \mathbf{H_P}, we need to use the definitions of WP(T)\mathbf{W_P}(T) and HP\mathbf{H_P} and employ some fundamental principles of information theory and entropy.

Recall:

WP(T)=i=1n(cidT(vi))\mathbf{W_P}(T) = \sum_{i=1}^{n} (c_i \cdot \mathrm{d_T}(v_i))
HP=i=1n(cilog2(ciSP))\mathbf{H_P} = - \sum_{i=1}^{n} \left( c_i \cdot \log_2 \left(\frac{c_i}{\mathbf{S_P}}\right) \right)

We start by rewriting HP\mathbf{H_P} in a more convenient form:

HP=i=1nci(log2(SP)log2(ci))=log2(SP)i=1ncii=1n(cilog2(ci))\mathbf{H_P} = \sum_{i=1}^{n} c_i \cdot \left( \log_2(\mathbf{S_P}) - \log_2(c_i) \right) = \log_2(\mathbf{S_P}) \cdot \sum_{i=1}^{n} c_i - \sum_{i=1}^{n} (c_i \cdot \log_2(c_i))

Since i=1nci=SP\sum_{i=1}^{n} c_i = \mathbf{S_P}, we get:

HP=SPlog2(SP)i=1n(cilog2(ci))\mathbf{H_P} = \mathbf{S_P} \cdot \log_2(\mathbf{S_P}) - \sum_{i=1}^{n} (c_i \cdot \log_2(c_i))

Let

K=i=1n2dT(vi)1,xi=2dT(vi)K.K=\sum_{i=1}^{n}2^{-\mathrm{d_T}(v_i)}\leq1, \qquad x_i=\frac{2^{-\mathrm{d_T}(v_i)}}{K}.

Then xi>0x_i>0 and ixi=1\sum_i x_i=1. By question (3),

i=1ncilog2xii=1ncilog2ciSP=HP.\sum_{i=1}^{n}c_i\log_2x_i \leq \sum_{i=1}^{n}c_i\log_2\frac{c_i}{\mathbf{S_P}} =-\mathbf{H_P}.

On the other hand,

i=1ncilog2xi=WP(T)SPlog2KWP(T),\sum_{i=1}^{n}c_i\log_2x_i =-\mathbf{W_P}(T)-\mathbf{S_P}\log_2K \geq-\mathbf{W_P}(T),

because K1K\leq1. Therefore WP(T)HP-\mathbf{W_P}(T)\leq-\mathbf{H_P}, or

WP(T)HP.\mathbf{W_P}(T)\geq\mathbf{H_P}.

Thus, we have shown that WP(T)HP\mathbf{W_P}(T) \geq \mathbf{H_P} for any ordered binary tree TTnT \in \mathbf{T_n} and any sequence P=(c1,c2,,cn)\mathbf{P} = (c_1, c_2, \ldots, c_n) of nn positive real numbers.

Knowledge

有序二叉树 哈夫曼树 信息论 拉格朗日乘数法 数学归纳法

重点词汇

  • Ordered binary tree 有序二叉树
  • Huffman tree 哈夫曼树
  • Depth 深度
  • Lagrange multipliers 拉格朗日乘子
  • Entropy 熵
  • Lagrange multiplier 拉格朗日乘数
  • Jensen's inequality 詹森不等式
  • Gibbs' inequality 吉布斯不等式
  • Kraft's inequality 克拉夫特不等式

参考资料

  1. Introduction to Algorithms, Chapter 16: Greedy Algorithms
  2. Information Theory, Inference, and Learning Algorithms, David J.C. MacKay