If there is a nested loop and also a single loop, then the time complexity will be estimated on the basis of the _______ loop only.
If there is a nested loop and also a single loop, then the time complexity will be estimated on the basis of the _______ loop only.
Solution
✅ Correct Option: 1
The nested loop runs about times, while the single loop runs only about times. In Big-O notation only the term that grows fastest is kept, so the nested loop decides the complexity.
Option 2: the single loop gives , which is smaller than for large , so it is dropped.
Options 3 and 4: the order in which loops appear in the code does not matter; only the loop with the highest growth rate counts.
Related questions:
2025: 14 May Shift 1
2026: 29 May Shift 2
2026: 23 May Shift 2