0% found this document useful (0 votes)
4 views2 pages

Lab 02

Đề ôn tham khảo lab2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Lab 02

Đề ôn tham khảo lab2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Code: TT/P.

KT&KĐCL/11/BM02E
FACULTY OF INFORMATION TECHNOLOGY
Issue time: 01
ACADEMIC YEAR: 20..... - 20......

Effect on date: 07/01/2019

SUBJECT: DESIGN AND ANALYSIS OF ALGORITHMS

CODE: 503040

Duration: 150 minutes

Allowed to use materials.

LAB 02: SOLVING RECURRENCE RELATIONS

I. Objective
In this laboratory, students practice solving recurrence relations. A
recurrence relation is the intermediate result generated from counting the number
of basic operations of a recursive algorithm. By solving recurrence relations, we
get a complexity function of the algorithm in its explicit form.
II. Master theorem
a) Formula of Master theorem is stated as follows:

b) Example 1
C (N) = C (2N/3) + 1 2N/3 = N / (3/2)
3
a=1 , b= , f ( N )=1∧f ( n ) ∈Θ ( n ) , therefore k=0
k
2

()
0
k 3
⇒ a=1=b =
2

⇒C ( N ) ∈ Θ ( N k logN )=Θ ( logN )

Thien Nguyen PAGE 1


Code: TT/P.KT&KĐCL/11/BM02E
FACULTY OF INFORMATION TECHNOLOGY
Issue time: 01
ACADEMIC YEAR: 20..... - 20......

Effect on date: 07/01/2019

c) Example 2
T(n) = 2T(n/2) + cn
A = 2, b = 2, k = 1, b k =2=¿ a=b k => T ( n ) ∈ Θ(nlogn)
d) Example 3
C(n) = 2C(n/2) + n – 1
a = 2, b = 2, k = 1, therefore a=b k
According to Master theorem, we have
C ( n ) ∈ Θ ( nk logn )

C ( n ) ∈ Θ ( nlogn )

III. Exercises: Solve the following recurrence relations with Master theorem
a. CN = CN/2 + 1000
b. CN = 3CN/2 + N
c. C (N) = 2C (N/2) + 1
d. CN = 4cN/2 + N
e. C (N) = 9C (N/3) + N
f. C (N) = C (2N/3) + 1
g. C (N) = 3C (N/4) + N2
h. T (n)=T (n/3)+2 T (n/3)+ √ n
2.5
i. T ( n )=T (n/3)+2 T ( n/3)+ n
3
j. T ( n )=T (n/3)+2 T ( n/3)+ n
3
k. T ( n )=T (n/3)+2 T ( n/3)+5

() ()
n n
l. T ( n )=T 3 +2 T 3 +n ×n

Thien Nguyen PAGE 2

You might also like