Time & Space Complexity - Hands-On
Time & Space Complexity - Hands-On
• Textbook
•Introduction to Algorithms 3rd ,Cormen,
Leiserson, Rivest and Stein, The MIT Press,
• Fundamentals of Computer Algorithms,
2nd, Sartaj Sahni, Ellis Horowitz,
Sanguthevar Rajasekaran
• Others
• Introduction to Design & Analysis Computer Algorithm 3rd,
Sara Baase, Allen Van Gelder, Adison-Wesley, 2000.
• Algorithms, Richard Johnsonbaugh, Marcus Schaefer, Prentice
Hall, 2004.
• Introduction to The Design and Analysis of Algorithms 2nd
Edition, Anany Levitin, Adison-Wesley, 2007.
Decide on : algorithm
design techniques etc.
Design an algorithm
Decide on : algorithm
design techniques etc.
Design an algorithm
Prove correctness
Decide on : algorithm
design techniques etc.
Design an algorithm
Prove correctness
➢ The complexity of an algorithm f(N) provides the running time and / or storage
space needed by the algorithm with respect of N as the size of input data.
Time complexity:
– How much time it takes to compute
– Measured by a function T(N)
Space complexity:
– How much memory it takes to compute
– Measured by a function S(N)
Complexity = O(logN)
Set k to 0.
While (k < n) and (a[k] is not key)
Add 1 to k.
If k == n Return –1.
Return k.
n/2i =1
n= 2i
=> i=log2n