When writing or using an algorithm, should the Big Oh complexity be mentioned?

closed as not constructive by user40980, user53019, Martijn Pieters, Frank Shearar, user7007 Feb 12 '13 at 19:00

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.

  • 6
    Only if you're showing your "O" face – adolf garlic Sep 9 '10 at 19:47

If you can back it up with real analysis, then yes, absolutely.

@Casebash test != analysis. If it should always be documented then just start throwing
// this algorithm is O(n!)
on every function.

I've worked with people who would say things like 'This function is O(1) because there are no loops', and then I would point to the call $(someHugeList).each(function(//...

  • 1
    Then perhaps the question should be "Should you do the analysis?" – finnw Sep 9 '10 at 19:18
  • @finnw Sorry, your point is...what exactly? – µBio Sep 9 '10 at 19:23
  • @downvoter Awesome down vote for a perfectly reasonable answer with no comment to explain. – µBio Sep 9 '10 at 19:43
  • I don't like this answer either. It should be always documented, even if you haven't tested it – Casebash Sep 9 '10 at 20:58
  • 1
    @Casebash: If you haven't analyzed your algorithm, then how can you know what its Big-O even is? Analysis (even very simply analysis) is a prerequisite. If you can't back up your statement of complexity, then it is wrong. – greyfade Sep 9 '10 at 21:16

Not the answer you're looking for? Browse other questions tagged or ask your own question.