Professional Documents
Culture Documents
of Algorithms
D r D i v ya S i n d h u L e k h a
A s s i sta n t P ro fe s s o r
https://www.enjoyalgorithms.com/blog/merge-sort-algorithm
https://mikebuss.com/2016/04/21/binary-search/
https://www.raywenderlich.com/5740-swift-algorithm-club-strassen-s-algorithm
➢ Solution – complexity
A. O(1)
B. O(log n)
C. O(n)
D. O(n log n)
Solution – complexity
✓ Divide
✓ Conquer (recursively)
✓ Combine
Solution:
We can use the substitution method to establish either upper or lower bounds
on a recurrence!
Step 1: Guess:
𝑇 𝑛 = 𝑂 (𝑛 log 𝑛 )
Note: 𝑐 ≥ 1
We can use the substitution method to establish either upper or lower bounds
on a recurrence!
Courtesy: https://www.codesdope.com
Cost
❑ Per-level cost : Sum of costs within each levels
❑ Total cost: sum of all the per-level costs.
❑ Assume n as power of 4.