+ 3
Algorithmic time complexity
Why is O(log n) considered more efficient than O(n) as the input size grows larger.
1 Answer
+ 9
Linear time (n) grows faster than logarithmic time (log n).
assume time used is 1 second
assume both algorithms produce the same output:
O(n), where n = 32, will take 32 seconds to compute
O(log n), where n = 32, will take 5 seconds to compute
Same number of elements/iterations/etc.; different times to reach the same result