Question 48Asked in DSSSB TGT Computer Science (Technical), 13 Sep 2025, Shift 3 (5:00 PM)

Consider the pseudocode of the function given below. abc(int n)

Consider the pseudocode of the function given below. abc(int n) { int i, j, k = 0; for (i = n/2; i <= n; i++) for (j = 2; j <= n; j = j * 2) k = k + n/2; return k; } what will the time complexity of the function abc() be?
  1. AO(n²)
  2. BO(n)
  3. CO(n log n)
  4. DO(log n)
Show answerHide answer

Correct answer: (C) O(n log n)

Explanation

The outer loop runs about n/2 times, and the inner loop doubles j, so it runs about log₂ n times. That gives O(n log n).

From DSSSB TGT Computer Science PYQ (Technical), 13 Sep 2025, Shift 3 (5:00 PM)

This is question 48 of DSSSB TGT Computer Science PYQ (Technical), 13 Sep 2025, Shift 3 (5:00 PM). See all questions of this paper with answers, or attempt the paper as a timed online test to get your score and all-India rank.