Chapter 1: Problem 26
What is the time complexity \(T(n)\) of the nested loops below? For simplicity, you may assume that \(n\) is a power of \(2 .\) That is, \(n=2^{k}\) for some positive integer \(k\) \(:\) \\[ \begin{array}{} \text { for }(i=1 ; i<=n, i++)\\} \\ \ \begin{array}{} j=n \\ \text { while }(j>=1)\\{ \end{array} \end{array} \\] < body of the while loop> \(\quad\) I/ Needs \(\Theta(1)\) \\[ j=\lfloor j / 2\rfloor \\] } }
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.