Recurrence Relations - (Divide and Conquer)
Recurrence Relations - (Divide and Conquer)
Recurrence Relation
Dividing Functions
Time Complexity of Recursive Algorithm Example 1
] 𝑛
2 ¿𝑇 ( )
23 +
¿𝑇 ( +3 ) 𝑛
23 3
¿𝑇 (
2𝑘)
𝑛
k
Time Complexity of Recursive Algorithm Example 1
] 𝑛
2 ¿𝑇 ( )
23 +
¿𝑇 ( )+3 𝑛
23
3
¿𝑇 (
2 𝑘 )+ k
𝑛
k
Time Complexity of Recursive Algorithm Example 1
¿𝑇 (
2 𝑘 )+ k
𝑛 𝑙𝑜𝑔 𝑛=k 𝑙𝑜𝑔 2 2
k
k
¿𝑇 ( +)log
𝑛
𝑛 n =1
+ log
¿ 1 n O (log n)
Time Complexity of Recursive Algorithm Example 2
]
2 ¿𝑇 ( 𝑛
22 )
+
+n
+n 𝑛
T(n)¿ 𝑇 ( )+ n
2
( +n 𝑛
¿𝑇 ( )+
] ( +n 23
( ) +n
¿𝑇 ( 𝑛
23 )n ( ) + n
Time Complexity of Recursive Algorithm Example 2
𝟏 𝟏
¿𝑇 ( 𝑛
+ n
23 ) (
𝟐
)𝟐 + n (
𝟐
)+ n 3
-------------------------------
¿𝑇 ( 𝑛
2𝑘 +) n( )+] k
Time Complexity of Recursive Algorithm Example 2
T(1) = 1 for n=1 f(n) denotes cost of the work done outside the recursive call, which includes:
cost of dividing the problem
cost of combining/merging the solutions
Time Complexity of Recursive Algorithm Example 3
2n
¿𝟐𝟑𝑇 ( +) 3 n
𝑛
23 3
Time Complexity of Recursive Algorithm Example 3
2n 2
¿𝟐𝟑𝑇 ( 𝑛
23 )3 n 3
-------------------------------
¿𝟐𝒌𝑇 ( 𝑛
2𝑘 )k n k
Time Complexity of Recursive Algorithm Example 3
References:
2.Chapter 8: Advanced Counting Techniques, “Discrete Mathematics and Its Applications” By Rosen (p-501)
YouTube Link
https://www.youtube.com/watch?v=pauQm5VxnO8&list=LL&index=13