8 comments

[ 2.9 ms ] story [ 34.0 ms ] thread
Just a reminder - seeking the lowest O doesn't always improve performance. Sometimes the startup cost for a lower O algorithm is too much.
See Galactic Algorithms for examples!
Also, in many cases, implementation details like cache locality mean that asymptotically inferior algorithms can in practice outperform those with a lower theoretical runtime complexity.
Better to tune this out even if you're a beginner. You normally don't say "The big O of the algorithm is ..." because it's ambiguous whether you are talking about time complexity or space complexity. Also, when someone says O(n), then n has to refer to something, normally the input size. The text area doesn't even have you define your input, and will say things like

for (i =0; i<x; i++) { }

is O(N), without even knowing what x is (could be a constant).

This hardly works at all so I am skeptical of the benefits it offers learners. Even using just for loops it gets tripped up and says the following code is O(n) when it isn't.

  for (int i = 0; i < n; i++) {
    for (int j = i; j < n; j++) {
    }
  }
Hmm, doesn't seem to work properly. Spits out a "Syntax error" for

  for (let i = 0; i < N*N; i++) {}