Computer Science · Algorithm Analysis
What is the worst-case time complexity of the following Python function? def function(n): count = 0 if n <= 0: return for i in range(0, n): j = 1 while j < n: j = j + i count = count + 1 print(count)
- 1O(n2)✓
- 2O(n)
- 3O(n log n)
- 4O(log n)
Correct answer
O(n2)
Download Single Question PDF
Save this question and verified answer as a clean study sheet with live clickable link.
Share with Friends & Study Groups
Challenge your peer aspirants on WhatsApp or Telegram to solve this question!
Preparing for Computer Science?
Practice full-length mock tests with real exam timers, instant score analysis, and all-India ranking.
Want more practice questions on Algorithm Analysis?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Algorithm Analysis