Tutorial 2
Tutorial 2
Steps:
٤ of ١Page
Princess Nora Bint Abdulrahman University First Semester 1433/1434H
Faculty of Computer and Information Science Tutorial # 2
CS 411 : Algorithms Design and Analysis Recursion Tree
Solution :
n
T(n) = 4T(n/2) +n
T(n/2) T( n/2) T(n/2 ) T( n/2)
n
T(n/2)=4T(n/4)+n/2
n/2 n/2 n/2 n/2
T(n/8)-----------------------------------------
٤ of ٢Page
Princess Nora Bint Abdulrahman University First Semester 1433/1434H
Faculty of Computer and Information Science Tutorial # 2
CS 411 : Algorithms Design and Analysis Recursion Tree
Level #of
Recursion tree Level Sum
# node
0 1 n n
٤ of ٣Page
Princess Nora Bint Abdulrahman University First Semester 1433/1434H
Faculty of Computer and Information Science Tutorial # 2
CS 411 : Algorithms Design and Analysis Recursion Tree
= 4 1 + 2
= 1 → ℎ = ← #1
2
from #1
= 1 + 2
= 1 + ,1 + 2 + 2 + ⋯ . . +2 /
6
1 6 − 1
4 = + 1 + 1 + … + 1 = 1>1
1−1
4+ 1 = 2 = 1
12 − 1
,1 + 2 + 2 + ⋯ + 2
/
= = 2 − 1
2−1
913 : #1
= 2$%&'( − 1
= $%&' − 1 = − 1 4+ 2 = 1
= 1 + − 1
= ;
٤ of ٤Page