東京大学 新領域創成科学研究科 メディカル情報生命専攻 2018年8月実施 問題7
Author
Description
To determine the order of
- At each node, if the order of all elements has been determined, let the node be a leaf and label it with the order of all elements. Otherwise, select a pair of elements
whose order has not yet been determined, and compare them. If , go to the left child node; otherwise, go to the right child node.
We call such a binary tree a decision tree. A decision tree shows how a sorting algorithm compares elements.
Answer the following questions:
(1) When
(2) Prove that in any decision tree, any order of all elements appears in one leaf but does not appear in different leaves.
(3) Let
为了确定
- 在每个节点,如果所有元素的顺序已经确定,则让该节点成为叶子并标记为所有元素的顺序。否则,选择一对顺序尚未确定的元素
,并比较它们。如果 ,则转到左子节点;否则,转到右子节点。
我们将这种二叉树称为决策树。决策树显示了排序算法如何比较元素。
回答以下问题:
(1) 当
(2) 证明在任何决策树中,所有元素的任何顺序出现在一个叶子中,但不会出现在不同的叶子中。
(3) 令
Kai
(1)
To sort
Shortest Path
For the shortest path in a decision tree, we follow a balanced comparison strategy that minimizes the number of comparisons.
-
Initial Comparison: Compare
with . - If
, proceed to the next comparison. - If
, swap and and then proceed.
- If
-
Subsequent Comparisons: Continue comparing each successive pair of elements in the sequence.
- Compare
with : - If
, continue. - If
, place correctly among and .
- If
- Compare
with , and so on, up to and .
- Compare
In the most optimal scenario, this process ensures that each comparison immediately determines the relative order of the two elements being compared, with a total of
For
In the optimal case, the path has
Longest Path
The longest path in a decision tree corresponds to the worst-case scenario where each comparison leads to the maximum possible number of subsequent comparisons. This often occurs when the sequence is in reverse order and we need to sort it into the correct order.
-
Initial Comparison: Compare
with . - If
, go to the right child node. - Otherwise, go to the left child node.
- If
-
Subsequent Comparisons: Continue comparing each pair of elements but always choosing the comparison that leads to the maximum number of steps.
- Compare
with : - If
, go to the right child node. - Otherwise, go to the left child node.
- If
- Continue this process for all
elements.
- Compare
In the worst-case scenario, the sequence is completely reversed, requiring
For
- Compare
with - Compare
with - Compare
with - Compare
with
- Compare
- Compare
- Compare
with - Compare
with - Compare
with
- Compare
- Compare
with
In the worst-case scenario, this process leads to a path with a length of
(2)
Existence
In any decision tree used for sorting
Leaf Node Representation: Each leaf node corresponds to a unique permutation of the
Thus, each possible permutation of the elements must be represented by at least one path from the root to a leaf. This ensures that any order of all elements appears in one leaf node, satisfying the existence condition.
Uniqueness
Now, we need to prove that any given order of all
- Unique Comparison Paths: Each leaf node in a decision tree is reached by a unique sequence of comparisons. This sequence determines a specific permutation of the elements. If two different paths lead to the same permutation, then at least one comparison in the paths, which is located in the common ancestor of the two paths, would have to result in a contradiction.
- Deterministic Nature of Comparisons: Each comparison
or provides a deterministic outcome. Once the comparison is made, the elements and are placed in a specific order relative to each other. Different sequences of comparisons lead to different permutations. - Conclusion: Therefore, any given order of all elements appears in exactly one leaf node and does not appear in different leaf nodes. This ensures the uniqueness condition.
(3)
To prove that
- Information-Theoretic Argument: The height of a decision tree represents the maximum number of comparisons needed in the worst case. For
elements, there are possible permutations (orders). Each comparison splits the set of possible permutations, providing one bit of information. - Lower Bound on Comparisons: The number of comparisons needed to distinguish between
permutations is at least . Using Stirling's approximation, , we get:
Ignoring lower-order terms, we have:
- Height Relation: The height
of the decision tree must be at least . Therefore:
where
Hence, we have shown that the height of the decision tree
Knowledge
决策树 排序算法 复杂度分析 信息论
重点词汇
- Decision Tree 决策树
- Comparison 比较
- Permutation 排列
- Information-Theoretic 信息论的
- Stirling's Approximation 斯特林近似
参考资料
- "Introduction to Algorithms" by Cormen, Leiserson, Rivest, and Stein, Chapter on Sorting and Order Statistics.
- "The Art of Computer Programming" by Donald Knuth, Volume 3: Sorting and Searching.