+ 1
Arrange the function in ascending order based on time complexity?(Questions in code as comments)
https://code.sololearn.com/ca0l2TtBuc1G/?ref=app https://code.sololearn.com/ca0l2TtBuc1G/?ref=app
1 Answer
0
1. n^(0.5) - O(ân) : This function has polynomial time complexity, O(ân). It grows slower than linear but faster than logarithmic.
2. log4n - O(log n) : This function has logarithmic time complexity, O(log n), but with a different base. It grows slower than nlogn.
3. n - O(n) : This function has linear time complexity, O(n). It grows linearly with the input size.
4. nlog2n - O(nlogn) : This function has logarithmic time complexity, O(nlogn). It grows faster than linear but slower than quadratic.
5. n² - O(n²) : This function has quadratic time complexity, O(n²). It grows quadratically with the input size.
6. 5^(log2n) - O(n^2.321) : This function can be simplified to n^(log2âľ), which is approximately n^2.321. It has polynomial time complexity, O(n^c), where đ is a constant.
7. 1 - 3âż - O(3âż) : This function has exponential time complexity, O(3âż). And n increases, the function grows rapidly.
8. 2^2n - O(2âż)