unit1
unit1
Analysis of
algorithm: Asymptotic analysis of complexity bounds – best,
average and worst-case behavior; Performance
measurements of Algorithm, Time and space trade-offs,
Analysis of recursive algorithms through recurrence
relations:
Substitution method, Recursion tree method and Masters’
theorem
5. Effectiveness: Each step must be basic enough to be performed exactly and in finite time.
6. Correctness: Must correctly solve the problem for all valid inputs.
Analysis of Algorithm
Goal: To predict the resources an algorithm needs (such as time and space) without implementing it.
Asymptotic Analysis
Asymptotic analysis describes the running time or space used by an algorithm in terms of input
size (n), when n becomes very large.
Types of Cases
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 1/3
Best Case: Minimum time required for inputs.
Average Case: Expected time over all inputs.
Space Complexity: Measures the amount of memory an algorithm uses relative to input size.
Example: Storing computed values (Memoization) saves time but uses more space.
Designing an algorithm often requires balancing time efficiency and space efficiency based on
requirements.
Steps:
Example:
T(n) = 2T(n/2) + n
Guess: T(n) = O(n log n)
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 2/3
Example (for T(n) = 2T(n/2) + n):
Level 0 cost: n
Level 1 cost: 2 × (n/2) = n
3. Master’s Theorem
Provides a direct way to find asymptotic behavior for recurrences of the form:
n
T (n) = aT ( ) + f (n)
b
Where:
T (n) = Θ(nlogb a )
Case 3: If f (n) = Ω(nlogb a+ϵ ) for some ϵ > 0 and regularity condition holds,
Would you also like a short summarized diagram (cheat-sheet style) for this? It can help you revise
faster before exams! 📄
Printed using ChatGPT to PDF, powered by PDFCrowd HTML to PDF API. 3/3