2016
Problem 7
Let denote the worst-case running time of an algorithm that processes input data of size . Let be the largest integer that is equal to or smaller than real number . Let be a constant number. Suppose that meets and each of the following recurrences for :
From the following complexity classes, select the smallest class for that satisfies each of the above recurrences, and prove the property: .
令 表示处理大小为 的输入数据的算法的最坏情况下的运行时间。令 为不大于实数 的最大整数。令 为一个常数。假设 满足 以及以下所有递归关系式():
从以下复杂度类中选择 满足每个上述递归关系的最小类,并证明该性质:。
Problem 8
Answer the following questions about linear algebra.
-
Compute the inverse matrix of the following matrix,
-
Consider data points in a two-dimensional space. Variance with respect to the x-axis, variance with respect to the y-axis, and covariance are respectively defined as
where denote the averages with respect to the x and y axes, respectively.
A: Compute the variance-covariance matrix
for the following data points, .
B: Compute all eigenvalues and eigenvectors of the variance-covariance matrix.
-
Prove that, if the eigenvalues of a regular matrix A are , those of the inverse matrix A are .
回答以下关于线性代数的问题。
-
计算以下矩阵的逆矩阵,
-
考虑数据点 在二维空间中。相对于 x 轴的方差、相对于 y 轴的方差和协方差分别定义为
其中 分别表示相对于 x 和 y 轴的平均值。
A: 计算方差-协方差矩阵
对于以下数据点,。
B: 计算方差-协方差矩阵的所有特征值和特征向量。
-
证明,如果一个正规矩阵 A 的特征值是 ,那么其逆矩阵 A 的特征值是 。
Problem 9
We sort an integer array, x. Answer the following questions, assuming that integer operations such as comparison, addition, subtraction, loading from memory, and storing to memory, take a unit time.
-
Fill (A) and (B) to complete the function below that constructs an array sorted in ascending order by merging two subarrays and , each of which is sorted in ascending order. You may write multiple lines if needed.
-
Fill (C) to complete the function below that takes an integer array as an input and outputs the sorted array . Array is a temporary array of the same size as .
-
Find the worst-case time complexity of sorting an integer array of size by
merge_sort()
. -
In order to accelerate sorting by
merge_sort()
, we implement a hardware that calculates a functioncmp(x1, x2, x3)
that returns 1 whenx1
is the smallest element amongx1
,x2
andx3
, 2 whenx2
is the smallest, and 3 whenx3
is the smallest. Show how to acceleratemerge_sort()
using the functioncmp()
. We assume that the functioncmp()
and branching by its return value take a unit time, respectively.
我们对整数数组 x 进行排序。回答以下问题,假设整数操作(如比较、加法、减法、从内存加载和存储到内存)占用单位时间。
-
填写 (A) 和 (B),以完成以下函数,该函数通过合并两个升序排列的子数组 和 来构造一个升序排列的数组 。如有需要,可以写多行代码。
-
填写 (C),以完成以下函数,该函数将整数数组 作为输入,并输出已排序的数组 。数组 是与 大小相同的临时数组。
-
通过
merge_sort()
找出对大小为 的整数数组进行排序的最坏情况下的时间复杂度。 -
为了加速
merge_sort()
排序,我们实现了一种硬件,它计算一个函数cmp(x1, x2, x3)
,当x1
是x1
、x2
和x3
中最小的元素时返回 1,当x2
是最小的时返回 2,当x3
是最小的时返回 3。展示如何使用函数cmp()
加速merge_sort()
。我们假设函数cmp()
和根据其返回值进行的分支分别占用单位时间。
Problem 10
In a directed graph, a path is a series of one or more arcs that connect a series of vertices. A cycle is a path that starts and ends on the same vertex. An Eulerian path (cycle, respectively) is a path (cycle) that visits every arc exactly once.
Next, we create a directed graph from string . Let denote , the substring of length that starts from position in . Let denote a directed graph such that the vertex set is , and the set of labeled arcs is , The 3rd argument is the label. Answer the following questions.
-
When , the vertex set and labeled arc set of are and , respectively. List all Eulerian paths and cycles in .
-
When , list all Eulerian paths and cycles in each of and .
-
A vertex is balanced if the number of arcs entering the vertex is equal to the number of arcs leaving the vertex. A directed graph is balanced if every vertex is balanced. A directed graph is connected if it has a path from any vertex to any vertex. Prove that a directed graph with an Eulerian cycle is connected and balanced.
-
Conversely, if a graph is connected and balanced, prove that the graph has an Eulerian cycle.
在有向图中,一条路径是连接一系列顶点的一条或多条弧。一个环是起点和终点在同一个顶点的路径。欧拉路径(或环)是一条恰好遍历每条弧一次的路径(或环)。
接下来,我们从字符串 创建一个有向图。令 表示从 中位置 开始的长度为 的子串 。令 表示一个有向图,其顶点集为 ,标记弧的集合为 ,第三个参数 是标签。回答以下问题。
-
当 时, 的顶点集和标记弧集分别为 和 。列出 中的所有欧拉路径和环。
-
当 时,列出 和 中的所有欧拉路径和环。
-
如果一个顶点的进入弧的数量等于离开弧的数量,则该顶点是平衡的。如果每个顶点都是平衡的,则有向图是平衡的。如果有向图从任意顶点到任意顶点都有路径,则它是连通的。证明一个有欧拉环的有向图是连通且平衡的。
-
反之,如果一个图是连通且平衡的,证明该图有一个欧拉环。
Problem 11
Suppose that there is an urn that contains black balls and white balls . You randomly draw balls with replacement . Answer the following questions with explanation.
-
Find the probability that you draw a black ball for the first time at the -th draw .
-
Suppose that you have drawn a black ball for the first time at the -th draw. Find the probability that you draw one or more black balls in the remaining draws.
Let be a random variable the value of which is 1 if the -th ball is black, and 0 otherwise . If necessary, you can use the equalities , and .
-
Find the expected value of .
-
Let . Find the expected value of .
-
Find the variance of .
假设有一个包含 个黑球和 个白球的罐子 。你随机有放回地抽取 个球 。回答以下问题并解释。
-
计算第一次在第 次抽到黑球的概率 。
-
假设你第一次在第 次抽到黑球。计算在接下来的 次抽中至少再抽到一个黑球的概率。
令 是一个随机变量,如果第 个球是黑色的,则其值为 1,否则为 0 。如果需要,你可以使用以下等式:,。
-
计算 的期望值 。
-
令 。计算 的期望值 。
-
计算 的方差 。
Problem 12
Assume that a global alignment of two sequences, and , is calculated by a dynamic programming using the iterative formula (A).
where is the score of aligning and , is the maximum score of the alignments of and . Assume that and that score is given to a gap of length . Answer the following questions (1) – (5).
-
Show the general form of .
-
Show the initial values for and for , so that the maximum score of the alignments of the two sequences and is obtained as after updating the iterative formula (A) for and . Notice that .
-
Evaluate the computational time of calculating the maximum score of the alignments of the two sequences and , and describe it by using and .
-
When updating formula (A) for and , is defined as follows:
Among the values of , and ,
when is the maximum, ,
otherwise, when is the maximum, ,
otherwise, .
Briefly explain, within five lines, about the role of in the alignment algorithm.
假设通过动态规划计算两个序列 和 的全局比对,使用迭代公式 (A)。
其中 是比对 和 的得分, 是 和 的比对的最大得分。假设 并且对于长度为 的空隙给定得分 。回答以下问题 (1) – (5)。
-
展示 的一般形式。
-
展示初始值 对于 和 对于 ,使得在更新迭代公式 (A) 之后,对于 和 ,两个序列 和 的比对最大得分为 。注意 。
-
评估计算 和 两个序列的比对最大得分的计算时间,并用 和 描述。
-
在更新公式 (A) 时,对于 和 , 定义如下:
在 , 和 的值中,
当 是最大值时,,
否则,当 是最大值时,,
否则,。
简要解释 在比对算法中的作用,限制在五行以内。