trac ng hiem

44
Trắc nghiệm Câu 1: T(n) sẽ bằng bao nhiêu ? nlog(n) nlog(2n) n 2 2nlog(n) Câu 2: Insertion sort can be expressed as a recursive procedure as follows. In order to sort A[1 ‥ n], we recursively sort A[1 ‥ n -1] and then insert A[n] into the sorted array A[1 ‥ n - 1]. Write a recurrence for the running time of this recursive version of insertion sort. Solution is T(n) = (n 2 ) Solution is T(n) = (n 2 ) B A D C B A Lam lai Dap An

Upload: linhden07

Post on 27-Oct-2014

137 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Trac Ng Hiem

Trắc nghiệm

Câu 1:

T(n) sẽ bằng bao nhiêu ?

nlog(n) nlog(2n) n2 2nlog(n)

Câu 2:Insertion sort can be expressed as a recursive procedure as follows. In order to sort A[1

‥ n], we recursively sort A[1 ‥ n -1] and then insert A[n] into the sorted array A[1 ‥ n -

1]. Write a recurrence for the running time of this recursive version of insertion sort.

Solution is T(n) = ⊝(n2)

Solution is T(n) = ⊝(n2)

Solution is T(n) = ⊝(n2)

Solution is T(n) = ⊝(2n)

DC

BA

DCBA

Lam lai

Dap An

Page 2: Trac Ng Hiem

Câu 3:Referring back to the searching problem (see Exercise 2.1-3), observe that if the sequence

A is sorted, we can check the midpoint of the sequence against v and eliminate half of the

sequence from further consideration. Binary search is an algorithm that repeats this

procedure, halving the size of the remaining portion of the sequence each time. Write

pseudocode, either iterative or recursive, for binary search. Argue that the worst-case

running time of binary search is Θ(lg n).

T(n)=T(n/2)+⊝(n), whose solution is T(n)=⊝(lg n)

T(n)=T(n/2)+⊝(1), whose solution is T(n)=⊝(lg n)

T(n)=T(n/2)+⊝(n), whose solution is T(n)=⊝(lg n2)

T(n)=T(n/2)+⊝(n), whose solution is T(n)=⊝(lg n)

Câu 4:Let A[1 ‥ n] be an array of n distinct numbers. If i < j and A[i] > A[j], then the pair (i, j)

is called an inversion of A.

b. What array with elements from the set 1, 2, . . . , n has the most inversions?

How many does it have?

There is a inversion (i,j). The number of such inversions is n(n-1)/2

There is a inversion (i,j). The number of such inversions is n(n-1)/3

There is a inversion (i,j). The number of such inversions is 2n(n-1)/2

There is a inversion (i,j). The number of such inversions is n(2n-1)/2

Câu 5:Dạng câu này chỉ cần nhớ cái đề hoặc nhớ thằng c1,c2,n0 là được

DC

BA

DC

BA

Page 3: Trac Ng Hiem

To show that (n + a)b =⊝(nb) we want to find constants c1, c2, n0 > 0 such that0<=c1nb <=(n+a)b <c2nb for all n>= n0.Thus, c1 = (1/3)b, c2=2b and n0 = 2 |a| satisfy the definition.

To show that (n + a)b =⊝(nb) we want to find constants c1, c2, n0 > 0 such that0<=c1nb <=(n+a)b <c2nb for all n>= n0.Thus, c1 = (1/3)b, c2=2b and n0 = 2 |a| satisfy the definition.

To show that (n + a)b =⊝(nb) we want to find constants c1, c2, n0 > 0 such that0<=c1nb <=(n+a)b <c2nb for all n>= n0.Thus, c1 = (1/3)b, c2=2b and n0 = 2 |a| satisfy the definition.

To show that (n + a)b =⊝(nb) we want to find constants c1, c2, n0 > 0 such that0<=c1nb <=(n+a)b <c2nb for all n>= n0.Thus, c1 = (1/2)b, c2=2b and n0 = 2 |a| satisfy the definition.

Câu 6:

Chọn đáp án đúng

2n+1 khác O(2n), 22n khác O(2n) 2n+1=O(2n), 22n = O(2n)

2n+1=O(2n), 22n khác O(2n) 2n+1 khác O(2n), 22n = O(2n)

Câu 7:

Chọn đáp án đúng

BA

DC

BA

DC

BA

Page 4: Trac Ng Hiem

⌈lg n⌉! is polynomially bounded.⌈lg lg n⌉! is polynomially bounded.⌈lg n⌉! is not polynomially bounded.⌈lg lg n⌉! is not polynomially bounded.

⌈lg n⌉! is not polynomially bounded.⌈lg lg n⌉! is polynomially bounded.⌈lg n⌉! is polynomially bounded.⌈lg lg n⌉! is not polynomially bounded.

Câu 8:

Chọn đáp án đúng

T(n)=⊝(n lg n) T(n)=⊝( lg n)

T(n)=⊝(2n lg n) T(n)=⊝(n lg 2n)

Câu 9:

T(n) = n T(n) = 2n

T(n) = 3n T(n) = 4n

Câu 10:

DC

BA

DC

BA

DC

Page 5: Trac Ng Hiem

T(n)=nlg n + 2n T(n)=nlg n + 3n

T(n)=nlg n + n T(n)=nlg n + 4n

Câu 11:a.

b.

Hai câu trên đúng hay sai ?

a đúng b sai a sai b đúng

Cả hai cùng sai Cả hai cùng đúng

Câu 12:a.

DC

BA

DC

BA

Page 6: Trac Ng Hiem

b.

Hai câu trên đúng hay sai ?

a đúng b sai a sai b đúng

Cả hai cùng sai Cả hai cùng đúng

Câu 13:

Câu trên đúng hay sai ?

Đ S

Câu 14:

DC

BA

DC

BA

Page 7: Trac Ng Hiem

Câu trên đúng hay sai ?

Đ S

Câu 15:

Câu trên sử dụng được phương pháp master hay không ?

Được Không

Câu 16:

Đúng hay sai ?

Đúng Sai

Câu 17:

DC

BA

DC

BA

DC

BA

Page 8: Trac Ng Hiem

Câu trên đúng hay sai ?

Đ S

Câu 18:a.

b.

c.

Câu nào đúng ?

a-b a-c

b-c All

Câu 19:a.

b.

DC

BA

DC

BA

Page 9: Trac Ng Hiem

c.

Tất cả những câu trên đều đúng. Học thuộc hết. Câu nào không sử dụng được master

method mà sử dụng recursion method?

a-b B

b-c All

Câu 20:a.

T(n)=

b.

c.

d.

e.

f.

DC

BA

Page 10: Trac Ng Hiem

g.

Tất cả những câu trên đều đúng. Học thuộc hết. Câu nào không sử dụng được master

method mà sử dụng recursion method?

a-b b

c-d f-g

Câu 21:a.

T(n)=

b.

c.

d.

DC

BA

Page 11: Trac Ng Hiem

e.

f.

g.

Tất cả những câu trên đều đúng. Học thuộc hết. Câu nào không sử dụng được master

method ?

Tất cả ngoại trừ a-b Tất cả ngoại trừ b

Tất cả ngoại trừ c-d Tất cả ngoại trừ f-g

Câu 22:

What are the minimum and maximum numbers of elements in a heap of height h?

At most= 2h+1 -1 and at least =2h At most= 2h+1 and at least =2h-1

At most= 2h+1 +1 and at least =2h At most= 2h+1 -1 and at least =2h-1

Câu 23:

DC

BA

DC

BA

Page 12: Trac Ng Hiem

Câu trên đúng hay không ?

Sai hoàn toàn Đúng

Câu 24:

The worst-case running time of heapsort is

Ω(n lg 3n). Ω(2n lg n).

Ω(n lg n). Ω(n lg 2n).

Câu 25:When all elements are distinct, the best-case running time of heapsort is

Ω(2n lg 2n). Ω(n lg n).

Ω(n lg2n). Ω(2n lg n).

Câu 26:

HEAP-EXTRACT-MAX(A)1 if heap-size[A] < 12 then error "heap underflow"3 max ← A[1]4 A[1] ← A[heap-size[A]]5 heap-size[A] ← heap-size[A] - 16 MAX-HEAPIFY(A, 1)7 return maxThe running time of HEAP-EXTRACT-MAX is

O(lg 2n) O(lg 3n)

DC

BA

DC

BA

DC

BA

DC

BA

Page 13: Trac Ng Hiem

O(lg n) O(lg 4n)

Câu 27:

HEAP-INCREASE-KEY(A, i, key)1 if key < A[i]2 then error "new key is smaller than current key"3 A[i] ← key4 while i > 1 and A[PARENT(i)] < A[i]5 do exchange A[i] ↔ A[PARENT(i)]6 i ← PARENT(i)The running time of HEAP-INCREASE-KEY on an n-element heap is

O(lg 3n), O(lg n),

O(lg 4n), O(lg 2n),

Câu 28:

MAX-HEAP-INSERT(A, key)1 heap-size[A] ← heap-size[A] + 12 A[heap-size[A]] ← -∞3 HEAP-INCREASE-KEY(A, heap-size[A], key)

The running time of MAX-HEAP-INSERT on an n-element heap is XXX

Để ý : In summary, a heap can support any priority-queue operation on a set of size n in XXX time.

XXX=O(lg n). XXX=O(lg 3n).

XXX=O(lg 2n), XXX=O(lg 4n), Câu 29:

PARTITION(A, p, r)1 x ← A[r]2 i ← p - 1

DC

BA

DC

BA

Page 14: Trac Ng Hiem

3 for j ← p to r - 14 do if A[j] ≤ x5 then i ← i + 16 exchange A[i] ↔ A[j]7 exchange A[i + 1] ↔ A[r]8 return i + 1

The running time of PARTITION on a subarray of size n is

Θ(2n). Θ(3n).

Θ(n). Θ(4n).

Câu 30:

Đúng hay sai ?

Đ S

Câu 31:

Quicksort's best-case running time is

Đúng hay sai ?

Ω(n lg n). Ω(2n lg n).

Ω(3n lg n). Ω(4n lg n).

DC

BA

DC

BA

DC

BA

Page 15: Trac Ng Hiem

Câu 32:

Consider a hash table of size m = 2p = 214 = 16384, w = 32. and a corresponding hash function h(k) = ⌊m(k A mod 1)⌋ for .A= (-1)/2. Compute the locations to which the key 123456 is mapped

h(k) = 67 h(k) = 68

h(k) = 69 h(k) = 70

Câu 33:

What statement about Red-black tree' property is true

a. No two reds in a row on a simple path from the root to a leafb. If a node is black, then both its children are red

c. For each node, all paths from the node to descendant leaves contain the same number of red nodes.

d. If a node is black, then its parent is red

Đáp án nào đúng ?

Câu 34:A red-black tree with n internal nodes has height at most

2 lg(n + 1). 2 lg(n + 2).

3 lg(n + 1). 2 lg(n + 3).

DC

BA

DC

BA

DC

BA

Page 16: Trac Ng Hiem

Câu 35:Suppose that we "absorb" every red node in a red-black tree into its black parent, so that

the children of the red node become children of the black parent. (Ignore what happens to

the keys.) What are the possible degrees of a black node after all its red children are

absorbed? What can you say about the depths of the leaves of the resulting tree?

Đáp án sau đúng hay không ?

After absorbing each red node into its black parent, the degree of each node blacknode is• 2, if both children were already black,• 3, if one child was black and one was red, or• 4, if both children were red.

Đ K

Câu 36:

The approach to algorithm design that reuses part of the solution search by storing values in memory is

(a) divide and conquer; (b) greedy; (c) brute force; (d) dynamic programming; (e) probabilistic

Đáp án nào đúng ?

a b

c dCâu 37:

A chain 〈A1, A2, A3〉 of three matrices. Suppose that the dimensions of the matrices are 10 × 100, 100 × 5, and 5 × 50, respectively.An optimal order for multiplying matrices that has the lowest cost (minimizes the number of scalar multiplications) is ((A1 A2) A3), for a total of 7500 scalar multiplications

DC

BA

DC

BA

Page 17: Trac Ng Hiem

An optimal parenthesization of a matrix-chain product whose sequence of dimensions is 〈30, 35, 15, 5, 10, 20, 25> is ((A1 (A2 A3)) ((A4 A5)A6))., for a total of 15125 scalar multiplications

Những điều trên đúng hay sai ?

Đ S

Hên xui Ai mà biết

Câu 38:

If the chain of matrices is 〈A1, A2, A3, A4〉, the product A1 A2 A3 A4 can be fully parenthesized in ________ distinct ways:

(A1 (A2 (A3 A4))) , (A1 ((A2 A3) A4))

((A1 A2) (A3 A4)) (((A1 A2) A3) A4).

Câu 39:

Use the substitution method to show that the solution to the recurrence (15.11) is

Ω(5n). Ω(2n).

Ω(3n). Ω(4n).

DC

BA

DC

BA

DC

BA

Page 18: Trac Ng Hiem

Câu 40:

Show that a full parenthesization of an n-element expression has exactly n - 1 pairs of

parentheses.

Câu trả lời trên đúng hay sai ?

Đ S

Hic Ko bít

Câu 41:

Determine an LCS of 〈1, 0, 0, 1, 0, 1, 0, 1〉 and 〈0, 1, 0, 1, 1, 0, 1, 1, 0〉.

Cách nhớ : 1001 con chó đóm + 10 con chó đóm. Hoặc 101 con chó đóm 2 lần.

(1,0,0,1,1,0) or (1,0,1,1,0,1) (1,0,0,1,1,0)

(1,0,0,1,1,0) (1,0,0,1,1,0)

Câu 42:

Which of the following statements is not true?

a) n2 + 2n + 6

DC

BA

DC

BA

Page 19: Trac Ng Hiem

b) n2

c) 2n+1

d) n!

Câu 43:

LCS-LENGTH(X, Y) 1 m ← length[X] 2 n ← length[Y] 3 for i ← 1 to m 4 do c[i, 0] ← 0 5 for j ← 0 to n 6 do c[0, j] ← 0 7 for i ← 1 to m 8 do for j ← 1 to n 9 do if xi = yj10 then c[i, j] ← c[i - 1, j - 1] + 111 b[i, j] ← ""12 else if c[i - 1, j] ≥ c[i, j - 1]13 then c[i, j] ← c[i - 1, j]14 b[i, j] ← "↑"15 else c[i, j] ← c[i, j - 1]16 b[i, j] ← ←17 return c and bThe running time of the procedure is ?

BA

DC

BA

Page 20: Trac Ng Hiem

O(2mn) O(mn)

O(3mn) O(n)

Câu 44:

An LCS (Longest common subsequence) of X= 〈A, B, C, B, D, A, B〉 and Y = 〈B, D, C, A, B, A〉.is ?Cách nhớ đề : X=Anh Bạn Có Bồ… Y= Bồ Dắt Công An Bắt Anh.

BCAB BABA

BCBA ( bồ cua bạn anh) BABA

Câu 45:

An LCS (Longest common subsequence) of X= 〈0, 1, 1, 0, 1, 0, 0, 1〉 and Y = 〈1, 1, 0, 1, 1, 0〉.is ?

<1, 1, 0, 1, 1> <1, 0, 0, 1, 0>

<1, 1, 1, 1, 0> <1, 1, 0, 1, 0> 1 mình, 1 máy, 0 lật bùa, 10 điểm

DC

BA

DC

BA

DC

Page 21: Trac Ng Hiem

Câu 46:

The length of An LCS (Longest common subsequence) of X= 〈A, B, C, B, D, A, B〉 and Y = 〈B, D, C, A, B, A〉is ? tìm chiều dài. Coi câu trên

4 5

7 6

Câu 47:

The number the number of scalar multiplications in optimal parenthesization of a matrix-chain product whose sequence of dimensions 〈10, 20, 50, 1, 100> is ?

Cách nhớ : 10 tuổi chưa bít yêu, 20 tuổi yêu lần đầu, 50 tuổi ở 1 mình đến 100 tuổi.

2100 2300

2230 2200 hai con ngỗng và hai trứng hột vịt

Câu 48:

An optimal parenthesization of a matrix-chain product whose sequence of dimensions 〈10, 20, 50, 1, 100> is ?

a.(A1 (A2 (A3 A4))) ,

b.(A1 ((A2 A3) A4)) ,

c.((A1 A2) (A3 A4)) ,

DC

BA

DC

BA

Page 22: Trac Ng Hiem

d.((A1 (A2 A3)) A4) , Anh cả quoánh không lại Anh 2 và Anh 3, Anh 4 chỉ ngồi nhìn

Câu 49:

CM : The number the number of scalar multiplications in optimal parenthesization of a matrix-chain product whose sequence of dimensions 〈5, 4, 6, 2, 7> is ?

157 158

159 160

Câu 50:

An optimal parenthesization of a matrix-chain product whose sequence of dimensions 〈5, 4, 6, 2, 7> is

Cách nhớ đề : hai số đầu và hai số sau 5+4=2+7 thì chọn đáp án là …

a.(A1 (A2 (A3 A4)))

b.((A1 (A2 A3)) A4) tương tự câu trên

c.(A1 ((A2 A3) A4))

d.((A1 A2) (A3 A4))

BA

DC

BA

DC

BA

Page 23: Trac Ng Hiem

Câu 51:

The number the number of scalar multiplications in optimal parenthesization of a matrix-chain product whose sequence of dimensions 〈30, 1, 40, 10, 25> is

30 năm 1cuộc tình

Hoặc 30 tuổi lấy 1 người vợ, đến 40 tuổi có 10 con

1400 1300

1100 1200

Câu 52:

CM : An optimal parenthesization of a matrix-chain product whose sequence of dimensions 〈30, 1, 40, 10, 25> is

a.(A1 (A2 (A3 A4)))

b.(A1 ((A2 A3) A4)) Anh cả cô đơn, (Anh 2 và Anh 3) gét anh 4

c.((A1 A2) (A3 A4))

d.((A1 (A2 A3)) A4)

Câu 53:

DC

BA

DC

BA

DC

Page 24: Trac Ng Hiem

OPTIMAL-BST(p, q, n)for i ← 1 to n + 1 do e[i, i 1] ← 0 w[i, i 1] ← 0for l ← 1 to n do for i ← 1 to nl + 1 do j ←i + l1 e[i, j ]←∞ w[i, j ] ← w[i, j1] + pj for r ←i to j do t ← e[i, r1] + e[r + 1, j ] + w[i, j ] if t < e[i, j ] then e[i, j ] ← t root[i, j ] ←r return e and root.The running time of Optimal Binary Search Tree is ?

O(2n3) O(2n3)

O(n2) O(n3)

Câu 54:Độ phức tạp của thuật toán nhân ma trận Strassen ?

O(2nlg7) O(nlg6)

O(nlg7) O(nlg5)

Câu 55:

DC

BA

DC

BA

Page 25: Trac Ng Hiem

Thuật toán trong đồ thị. Độ phức tạp của Kruskal và Prim's algorithm là ?

Đáp án sau cho câu hỏi trên có đúng ko?

prim = O(E+ V logV). E edge and V vertex.

kurskal = O(E lgV ) tương đương với O(E log E). Where E is the number of edges in the graph and V is the number of vertices

Đ S

Câu 56:

Function g is an upper bound on function f iff for all x:

(a) g(x) ≤ f (x);

(b) g(x) ≥ f (x);

(c) g = O( f );

(d) f =Ω(g)

DC

BA

DC

BA

Page 26: Trac Ng Hiem

Câu 57:

Function g is a lower bound on function f iff for all x:

(a) g(x) ≤ f (x);

(b) g(x) ≥ f (x);

(c) f = O(g);

(d) g =Ω(f);

Câu 58:

Big-Omega notation expresses

(a) tight bounds;

(b) upper bounds;

(c) lower bounds;

(d) worst cases;

DC

BA

DC

BA

Page 27: Trac Ng Hiem

Câu 59:

Big-O notation expresses (a) tight bounds; (b) upper bounds; (c) lower bounds; (d) best cases

Câu 60:

Theta notation expresses (a) tight bounds; (b) upper bounds; (c) lower bounds; (d) worst cases

Câu 61:

The theorem, T1(n) ∈ Θ(g1(n)) ∧ T2(n) ∈ Θ(g2(n)) ⇒T1(n) + T2(n) ∈ Θ(maxg1(n), g2(n)) says that (a) the slower and faster parts of an algorithm together set its running time; (b) the faster part of an algorithm dominates in determining running time; (c) the slower part of an algorithm dominates in determining running time; (d) Algorithm T computes functions g1 and g2;

DC

BA

DC

BA

DC

BA

Page 28: Trac Ng Hiem

Câu 62:

Quadratic time is faster than(a) Θ(1)(b) Θ(lg n)(c) Θ(n2)(d) Θ(n3)

Câu 63:

Best case for an algorithm (a) takes the same time forall data (b) assumes the data that the algorithm handles in the greatest time (c) assumes the data that the algorithm handles in the least time (d) is the expected time considering all possible input data

Câu 64:

Worst case for an algorithm (a) takes the same time for all data (b) assumes the data that the algorithm handles in the greatest time (c) assumes the data that the algorithm handles in the least time (d) is the expected time considering all possible input data

DC

BA

DC

BA

DC

BA

Page 29: Trac Ng Hiem

Câu 65:

Average case for an algorithm (a) takes the same time for all data (b) assumes the data that the algorithm handles in the greatest time (c) assumes the data that the algorithm handles in the least time (d) is the expected time considering all possible input data

Câu 66:

Bubble sort’s worst-case running time function is determined by (a) a single loop(b) nested loops(c) a series of loops(d) the input data

Câu 67:

A loop nested to two levels, each with roughly n iterations, has running time (a) O(1)(b) O(n)(c) O(n2)(d) O(n lg n)

BA

DC

BA

DC

BA

Page 30: Trac Ng Hiem

Câu 68:

The running time function of an algorithm is determined by (a) the number of operations in a sequence structure (b) the number of branches in a selection structure (c) the time of the slowest of a series of loops (d) the data

Câu 69:

Recurrence relations enable us to use _____ to obtain running time (a) empirical tests(b) loop nesting;(c) base-case running time(d) base-case running time and depth of recursion

Câu 70:

Brute-force algorithms make use of :(a) a straightforward solution to a problem by examining all possible solutions (Brute-force)

DC

BA

DC

BA

DC

Page 31: Trac Ng Hiem

(b) the fact that an optimal solution can be constructed by adding the cheapest next component, one at a time (Greedy)(c) The fact that data is arranged so that at each step, half the remaining input data can disposed of (Divede and conquer)(d) effort can be saved by saving the results of previous effort in a table; (dynamic programming)

Câu 71:

The linear search is what kind of algorithm? (a) divide and conquer; (b) greedy (c) brute force (d) dynamic programming

Câu 72:

The Binary search is what kind of algorithm? (a) divide and conquer (b) greedy (c) brute force (d) dynamic programming

DC

BA

DC

BA

DC

BA

Page 32: Trac Ng Hiem

Câu 73:

Inserting an element in a sorted array so that it stays sorted is(a) O(1); (b) O(lg n); (c) O(n);(d) O(n lg n);

Câu 74:

Linear search is O(___) (a) 1(b) lg n;(c) n;(d) n2;

Câu 75:

What is the running time of a brute-force algorithm that finds the minimum element of an array? (a) O(1);(b) O(lg n); (c) O(n);

DC

BA

DC

BA

Page 33: Trac Ng Hiem

(d) O(n lg n);

Câu 76:

The BST search uses which approach to algorithm design? (a) divide and conquer(b) greedy(c) brute force(d) dynamic programming;

Câu 77:

After each step of the BST search, the quantity of remaining data to be searched is on average(a) 1;(b) lg n; (c) n ÷ 2(d) n;

DC

BA

DC

BA

DC

BA

Page 34: Trac Ng Hiem

Câu 78:

The height of a BST is on average O(__) (a) 1; (b) lg n; (c) n; (d) n lg n

Câu 79:

Hill climbing is a(n) ____ approach(a) divide-andconquer;(b) brute-force;(c) greedy; (d) dynamicprogramming;(e) probabilistic

Câu 80:

Let (u, v) be a minimum-weight edge in a graph G. Show that (u, v) belongs to some minimum spanning tree of G.

Đáp án sau đúng hay không ?Let A be a subset of some MST T such that (u, v) e A. To choose an edge to be added to A, all the edges on the cut are considered and an edge with lowest weight is selected. Since (u, v) is the minimum weight edge in the graph G, it gets selected on some cut.

Đ S

BA

DC

BA

DC

BA

Page 35: Trac Ng Hiem

Câu 81:

Let e be a maximum-weight edge on some cycle of G = (V, E). Prove that there is a minimum spanning tree of G′ = (V, E -e) that is also a minimum spanning tree of G. That is, there is a minimum spanning tree of G that does not include e.

Đáp án sau đúng hay không ?For simplicity, assume a cycle (C*) in G contains three edges: el = (1,2), e2=(2,3), e3=(l,3), so that wtl = max(wtl, wt2, wt3) A minimum spanning tree on G cannot include all el, e2, e3 as it would form a cycle and violate the tree property

During the course of Generic-MST algorithm an edge from C will be considered for inclusion in A if it contains a safe edge According to Theorem 23.1, it can be a light edge crossing a cut (S. V-S) that respects A

The cut (S, V-S) therefore does not respect C. (Otherwise, no edge in C crosses the cut) If el crosses the cut, it is easy to see that at least one more edge in C crosses the cut. Since el has the maximum weight, it will not be chosen to be included in A. Note that, this will be true even when some edges from C are already included in A Hence, we can select safe edges in such a way that they will never include el The above proof can be readily generalized to a cycle of any size.

Đ S

Câu 82:

Let T be a minimum spanning tree of a graph G, and let L be the sorted list of the edge weights of T. Show that for any other minimum spanning tree T′ of G, the list L is also the sorted list of edge weights of T′.

Câu này mà có đáp án chắc cũng chẳng ai học. Đọc và nhớ đề thôi.

DC

BA

DC

Page 36: Trac Ng Hiem

Đ S

Câu 83:

The length of An LCS (Longest common subsequence) of X= 〈president> and Y = <providence>

Chiều dài là bao nhiêu? -> priden

3 4

5 6

Câu 84:

LCS of “Algorithm” và “Alignment”

Alim Ali

Al Alimt

DC

BA

DC

BA

DC

BA

Page 37: Trac Ng Hiem

Câu 86:

The length of an LCS (Longest common subsequence) of X= <springtime> and Y =<printing> is

Printi - 6 Print - 5

Printim - 7 Prin - 4

Câu 87:

An LCS (Longest common subsequence) of X= ncaatournament and Y = <northcarolina> is

ncarna ncarn

ncar nc

Câu 88:

An LCS (Longest common subsequence) of X= <basketball> and Y = <krzyzewski> is

ke sk

Ko có k

DC

BA

DC

BA

DC

BA

Page 38: Trac Ng Hiem

Câu 89:

An LCS (Longest common subsequence) of X= <basketball> and Y = <snoeyink> is

sk se

Ko có s

DC

BA