Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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

share|improve this question

closed as not constructive by MichaelT, GlenH7, Martijn Pieters, Frank Shearar, Glenn Nelson 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
add comment

1 Answer 1

up vote 9 down vote accepted

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(//...

share|improve this answer
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
show 4 more comments

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