+ 3

Algorithmic time complexity

Why is O(log n) considered more efficient than O(n) as the input size grows larger.

25th Jan 2025, 5:13 AM
Mustafa Raza
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
25th Jan 2025, 5:29 AM
怌ļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć€
怌ļ¼Øļ¼”ļ¼°ļ¼°ļ¼¹ ļ¼“ļ¼Æ ļ¼Øļ¼„ļ¼¬ļ¼°ć€ - avatar