Practice free →
HomeGATE CSEcomputerscienceAlgorithms › A nested loop runs the inner body `n` times for …

A nested loop runs the inner body `n` times for each of `n` outer iterations, with constant work per inner iteration. Its total operation count is approximately

Alinear in n
Bquadratic in n (∝ n²)
Clogarithmic in n
Dconstant, independent of n
Answer & Solution
Correct answer: B. quadratic in n (∝ n²)
Two nested loops each running n times produce n × n = n² inner iterations. Constant work per iteration means total work is proportional to n². This is the classic quadratic-time pattern; algorithms like bubble sort or selection sort follow this shape.
Solve this in the app — GATE CSE practice & 24k+ MCQs →
Related questions