Question-17
Python programming
Time complexity
Consider the following function:
Which one of the following most closely approximates the return value of the function fun1?
NoteAnswer
NoteSolution
The outer loop runs \(n - 1\) times. The first inner loop increments \(p\) until \(j\) becomes \(1\), which takes \(\log n\) iterations. The second inner loop increments \(q\) until \(k\) reaches \(p\), which takes \(\log p\) iterations. Therefore, the return value \(q\) is closely approximated by \(n \log(\log n)\).