算法复习题

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

1.The O-notation provides an asymptotic upper bound. The Ω-notation provides an

asymptotic lower bound. The Θ-notation asymptotically a function form above and below.

2.To represent a heap as an array,the root of tree is A[1], and given the index i of a

node, the indices of its parent Parent(i) { return ⎣i/2⎦; },left child, Left(i)

{ return 2*i; },right child, right(i) { return 2*i + 1; }.

3.Because the heap of n elements is a binary tree, the height of any node is at most

Θ(lg n).

4.In optimization problems, there can be many possible solutions. Each solution

has a value, and we wish to find a solution with the optimal (minimum or maximum) value. We call such a solution an optimal solution to the problem.

5.optimal substructure if an optimal solution to the problem contains within it

optimal solutions to subproblems.

6. A subsequence of X if there exists a strictly increasing sequence of

indices of X such that for all j = 1, 2, ..., k, we have x i j= z j .

Let X = and Y = be sequences, and let Z =

z2, ..., z k> be any LCS of X and Y.

(1). If x m = y n, then z k = x m = y n and Z k-1 is an LCS of X m-1 and Y n-1.

(2). If x m ≠ y n, then z k ≠ x m implies that Z is an LCS of X m-1 and Y.

(3). If x m ≠ y n, then z k ≠ y n implies that Z is an LCS of X and Y n-1.

7. A greedy algorithm always makes the choice that looks best at the moment. That

is, it makes a locally optimal choice in the hope that this choice will lead to a

globally optimal solution.

8.The greedy-choice property and optimal sub-structure are the two key ingredients

of greedy algorithm.

9.When a recursive algorithm revisits the same problem over and over again, we

say that the optimization problem has overlapping subproblems.

10.greedy-choice property is a globally optimal solution can be arrived at by making

a locally optimal (greedy) choice.

11.An approach of Matrix multiplication can develope a Θ(V4)-time algorithm for

the all-pairs shortest-paths problem and then improve its running time to Θ(V3lg V).

12.Floyd-Warshall algorithm, runs in Θ(V3) time to solve the all-pairs

shortest-paths problem.

13.The running time of Quick Sort is O(n lg n)in the average case, and O(n2) in the

worst case.

14.The MERGE(A,p,q,r) procedure in merge sort takes time Θ(n).

15.Given a weighted, directed graph G = (V, E) with source s and weight function w :

E →R, the Bellman-Ford algorithm makes |V| - 1 passes over the edges of the

graph.

16.The Bellman-Ford algorithm runs in time O(V E).

17.A decision tree represents the comparisons made by a comparison sort.The

asymptotic height of any decision tree for sorting n elements is Ω(n lg n).

相关文档
最新文档