2023

Problem 7

Given a point set, , the convex hull, , is a convex polygon such that comprises a subset of arranged in a clockwise order and that all points in are included in or on the edge of the polygon. Below is an example.

  1. The algorithm shown below computes from a given . Show the complexity of line 4-7 in the notation. Explain the reason. Arithmetic operations over real numbers have infinite precision and can be computed in a unit time. returns true only if and turns clockwise (i.e., the cross product is negative).

    1: Let be an empty stack. We denote by the -th element from top of .

    2: Take the bottommost point of the leftmost points in , and let it be .

    3: Leave out of , sort in order of the slope of the line from to . Let the result be .

    4: for in :

    5: while the size of and not :

    6: pop an element from

    7: push to

  2. Suppose is given. Let , and we computed the convex hull for . Given , prove that the sorted array of can be computed in linear time in terms of .

  3. Prove that the complexity of an algorithm that computes the convex hull of points (not necessarily the algorithm shown in (1)) is not smaller than the complexity of a sorting algorithm for elements.

  4. Suppose we use a random function that returns true/false at 50% of probability, respectively. Prove that we need to call at least times to output one of all possible permutations of integers from 1 to with the equal probability.

  5. Consider a computation model where the sorting algorithm with the smallest complexity is based on comparison between two numbers. Prove that the complexity of computing a convex hull is intrinsically . Use the Stirling’s approximation formula, , if need be.


给定一个点集 ,凸包 是一个凸多边形 ,使得 组成一个按顺时针顺序排列的 的子集,并且 中的所有点都包含在多边形的边上或边上。以下是一个例子。

  1. 下列算法从给定的 计算 。展示 4-7 行的复杂度(用 表示)。解释原因。实数上的算术运算具有无限精度,可以在单位时间内完成。只有当 顺时针旋转时(即,叉积 为负时), 才返回真。

    1: 令 为一个空栈。我们用 表示 顶部的第 个元素。

    2: 取 中最左边点的最底部点,记为

    3: 去掉 中的 ,按从 的斜率排序。结果记为

    4: 对 中的每个 :

    5: 当 的大小大于 1 且 不成立时:

    6: 从 中弹出一个元素

    7: 将 推入

  2. 假设给定 。令 ,我们计算出 的凸包 。给定 ,证明 的排序数组可以在线性时间内计算。

  3. 证明计算 个点的凸包(不一定是算法 (1) 中所示的算法)的复杂度不小于排序 个元素的算法的复杂度。

  4. 假设我们使用一个以 50% 的概率分别返回真/假的随机函数。证明我们至少需要调用 次才能输出从 1 到 的所有可能排列中的一个且概率相等。

  5. 考虑一个基于两个数之间比较的最小复杂度排序算法的计算模型。证明计算凸包的复杂度本质上是 。如果需要,使用 Stirling 近似公式


Question 8

(1) Describe the eigenvalues and eigenvectors of the following matrix. ( is a real value.)

(2) What is the range of such that is positive semidefinite.

(3) Consider an symmetric matrix where all diagonal elements are and all non-diagonal elements are . Show that this matrix is non-singular when .


(1) 描述下列矩阵的特征值和特征向量。( 是一个实值。)

(2) 使 是半正定矩阵的 的范围是什么。

(3) 考虑一个 的对称矩阵,其中所有对角线元素是 ,所有非对角线元素是 。证明当 时,这个矩阵是非奇异的。


Question 9

Let be a directed acyclic graph such that is the set of integers from to . We will consider the following sets of edges for .

  1. Consider a bijective function from to such that for any . For each of and , answer the number of all different bijective functions and the rationale.

  2. For each of and , answer the number of all different paths from to (or a recurrence for computing the number), and the rationale.

  3. For any directed acyclic graph , design an algorithm that calculates the number of paths from to in time for any , and explain the rationale.


为一个有向无环图,其中 是从 的整数集合 。我们将考虑以下边集

  1. 考虑从 的一个双射函数 使得对任何 ,有 。对于 ,回答所有不同双射函数的数量和理由。

  2. 对于 ,回答从 的所有不同路径的数量(或用于计算数量的递推关系),并说明理由。

  3. 对于任意有向无环图 ,设计一个算法,该算法在 时间内计算从 的路径数量(对于任意 ),并解释理由。


Question 10

There are two points , and data points in a 2-dimensional Euclidean plane. Assume that the distance between and , and the distances between and the data points are given. The distances between and the data points are not given, but a function defined below can be used to identify the sign of for .

Assume that for any .

  1. Show the pseudo-code of an algorithm to sort by ascending order of the distances from in worst computational time.
  2. Explain why the worst computational time of the algorithm shown in (1) is .
  3. Prove that if then .
  4. When are already sorted by ascending order of the distances from , show an algorithm to sort by ascending order of the distances from that calls function the minimum number of times, and evaluate that number of times.

在二维欧几里得平面上有两个点 以及 个数据点 。假设点 之间的距离为 ,并且给出了点 和数据点之间的距离 。点 和数据点之间的距离 未知,但可以使用以下定义的函数 来确定 的符号,对于

假设对于任何

  1. 给出一个伪代码算法,将 按距离 的升序排序,最坏计算时间为
  2. 解释为什么 (1) 中所示算法的最坏计算时间为
  3. 证明如果
  4. 已经按距离 的升序排序时,给出一个算法按距离 的升序排序,该算法调用函数 的次数最少,并评估调用次数。

Question 11

Let be a random sequence of non-negative integers generated by the following rules.

(i) If , with probability , and with probability .

(ii) If , with probability 1.

In the following, is assumed. Further, we define as the probability that at time with initial value (: a nonnegative integer). Answer the following questions.

  1. Answer the probability that given .
  2. Answer the probability that given .
  3. Express using and (, ).
  4. Let . Derive the equations that the s satisfy using (3).
  5. Answer the condition for that the equations of (4) have a solution with , as well as the solution (Examine the case: ).

为通过以下规则生成的非负整数随机序列。

(i) 如果 ,则 ,概率为 ,概率为

(ii) 如果 ,则 ,概率为 1。

在下文中,假设 。此外,我们定义 为在初始值 (:非负整数) 时, 的概率。回答以下问题。

  1. 回答在 的概率。
  2. 回答在 的概率。
  3. 使用 表示 (, )。
  4. 。推导出 满足的方程(使用 (3))。
  5. 回答 的条件,使得 (4) 中的方程有解 ,且 ,以及解 (检查情况:)。

Question 12

We would like to know the probability that the string appears in a random protein sequence. Assume the sequence has random independent letters from the protein alphabet , and letter has probability . Define to be the probability that appears in a random sequence of length , given that the sequence ends with , where is a length-4 string.

  1. What is when ?

  2. What is when ?

Define to be without its final letter. Define to be with letter prepended to it. These definitions may be useful to answer the following questions.

  1. What is , in terms of , where is any length-4 string, when ?

  2. What is when ?

Define to be the product of the probabilities of the letters in . Define to be the set of all possible length-4 strings. These definitions may be useful to answer the following question.

  1. What is the probability that appears in a random sequence of length , in terms of ?

我们想知道字符串 出现在随机蛋白质序列中的概率。假设序列中的字母是蛋白质字母表 中的随机独立字母,并且字母 的概率为 。定义 出现在长度为 的随机序列中的概率,前提是序列以长度为 4 的字符串 结尾。

  1. 时, 是多少?

  2. 时, 是多少?

定义 为去掉最后一个字母后的 。定义 为在 前添加字母 后的 。这些定义可能对回答以下问题有用。

  1. 时, 表示,其中 是任意长度为 4 的字符串?

  2. 时, 是多少?

定义 中字母概率的乘积。定义 为所有可能的长度为 4 的字符串的集合。这些定义可能对回答以下问题有用。

  1. 的基础上, 出现在长度为 的随机序列中的概率是多少?