DSAL-210-Lecture 2 - Understanding Algorithm Complexity
DSAL-210-Lecture 2 - Understanding Algorithm Complexity
UNDERSTANDING ALGORITHM
COMPLEXITY
By
W.G. Gondwe
Lecturer, Computer Networks
CS&IT Department
Malawi University of Science & Technology
Overview
• Revisting Time and Space Complexities
• Why We Analyse Algorithm Complexity
• Factors Affecting Complexity
• Best, Average and Worst Case Complexity
• How We Analyze Complexity
• Class Exercise
• Similarly:
• While searching, our algorithm may require 500 CPU cycles, each
lasting 2 nanoseconds (a total of 1000ns)
• A different algorithm may require 300 CPU cycles, depending on how
we design it
• In this case, the second algorithm is less complex in terms of time
than the first one
14