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.
Related questions
An NP-hard problem differs from an NP-complete one because NP-hard problemsThe first problem proved to be NP-complete wasA problem X is NP-complete if and only ifWhy does theoretical computer science draw the line at 'polynomial-time' for tractability?Which set inclusion is established (i.e., proven, not open)?The class NP is the set of decision problems for whichFloyd-Warshall detects the presence of a negative cycle byTopological sort is well-defined for