Computer Science · Analysis of Algorithms
Consider the following function: int func(int n) { int s = 0; while (n > 1) { n = n / 2; s++; } return s; } What is the asymptotic time complexity of this function with respect to n?
- 1O(n log n)
- 2O(log n)✓
- 3O(n)
- 4O(n2)
Correct answer
O(log n)
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 Analysis of Algorithms?
Solve complete topic-wise tests with detailed solutions on GkGet.
Related Practice Questions
Recommended practice questions in Computer Science · Analysis of Algorithms