What is O(N^2) Quadratic Time?
It is a time complexity where the execution time grows proportionally to the square of the input size, typically caused by checking every item against every other item.
Verify This Answer
Cross-check this information using these trusted sources:
More FAQs in O(N^2) Quadratic Time: Recognizing Inefficiencies
No, only if both loops scale with N. If the outer loop runs N times and the inner loop runs a fixed 5 times, it is O(5N), which simplifies to O(N).
A TLE error on coding platforms almost always means you submitted an O(N^2) nested-loop solution when the platform was testing with a massive input expecting an O(N) solution.
Yes, for intrinsically 2D problems like traversing an N x N matrix, or for sorting very tiny arrays where the overhead of complex O(N log N) algorithms isn't worth it.
Still have questions?
Browse all our FAQs or reach out to our support team
