Time & Space Complexity - Hands-On
Time & Space Complexity - Hands-On
Decide on : algorithm
design techniques etc.
Design an algorithm
Decide on : algorithm
design
designtechniques
techniques
etc.
Design an algorithm
Prove correctness
Decide on : algorithm
design
designtechniques
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