Facebook Pixel
Understanding the Time Complexity of O(n^2)

What is the time complexity of 3 nested loops?

The answer

If all three loops iterate N times, the complexity is O(N^3), or Cubic Time, which is extremely slow and only acceptable for tiny datasets.

More FAQs in Understanding the Time Complexity of O(n^2)

It is Quadratic Time. It means the execution time of an algorithm grows proportionally to the square of the input size.

No. If the inner loop bounds are constant (e.g., it always runs 10 times regardless of N), the overall complexity remains O(N).

Because the number of operations explodes exponentially. For an input of 100,000, an O(N^2) algorithm requires 10 billion operations, which takes too long for standard CPUs.

Still have questions?

Browse all our FAQs or reach out to our support team

Want to upskill yourself?

Your learning library

Small steps. Big possibilities.

Find your next course. Build something great.

Our courses are taking a Coffee break, but your curiosity shouldn't. Stay engaged with namastedev linkedin, youtube, discord and other resources while you wait.

0

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.

Success

Please Login.