I have a question about analyzing the asymptotic runtime complexity of a few short snippets of code in Ruby. I made a rough analysis of the complexity of the code snippets, but another user disagreed with my analysis, so I wanted to ask the community at large about what the correct complexity is.

I was wondering on which Stack Exchange site such a question should be asked:

  1. StackOverflow?

    • According to What topics can I ask about here?, questions about "software algorithms" can be asked.

    • Also, Complexity-Theory and Big-O tags are there, and have 1,000+ questions tagged.

    • StackOverflow looks like it might be a good fit because it involves specific lines of code in a specific language, Ruby.

  2. Programmers?

    • I checked What topics can I ask about here?, and it says "algorithm and data structure concepts". I already understand the general concepts of asymptotic complexity analysis, I learned it in college. I'm just asking about the complexity of a specific instance of code, so I don't think my question belongs on Programmers, correct?

    • Programmers also has Big-O and Complexity tags, but there are less than a 100 questions tagged for each.

  3. Computer Science?

    • What topics can I ask about here? says "This site covers theoretical and applied computer science at any level, including but not limited to...algorithms, models of computation". I can ask about applied computer science, so this looks like it might be a good fit too. Yes, my example code is in Ruby, but my analysis of its runtime complexity isn't necessarily tied to individual Ruby methods and implementation, it's actually kind of language-agnostic.

    • Computer Science has Complexity-Theory and Asymptotics tags, both of which have a few hundred questions tagged each (much more than in Programmers).

  4. Code Review?

    • What topics can I ask about here? says: "Code Review Stack Exchange is for sharing code from projects you are working on for peer review. If you are looking for feedback on a specific working piece of code from your project in the following areas...Performance". My question is related to the performance of a specific piece of Ruby code. But I'm more interested in verifying if my asymptotic analysis of it is correct, rather than trying to improve the performance, but of course finding a way to improve the performance to O(n log n) instead of O(n^2) would be a nice bonus.

    • Code Review has a single Complexity tag with just 28 questions tagged.

So based on the above, Programmers seems like the least appropriate place to post my specific question. But I'm very unsure of which of the other three Stack Exchange sites would be a better fit.


1 Answer 1


If the question contains actual code, I'd say Stack Overflow is more appropriate (as I remember, CS and Programmers aren't too fond of actual code in posts).

If it contains pseudo-code, go for Computer Science (although I believe it isn't off topic for either Stack Overflow or Programmers).

Don't ask on Code Review if you're asking about the complexity. If asking to improve the complexity, you could perhaps ask on Code Review, but improving complexity often involves a complete rewrite, which I'm pretty sure isn't what Code Review is about, so it would probably be best suited on Stack Overflow / Computer Science (based on whether it's actual code or pseudo-code). But do separate asking about the complexity and asking about improving the complexity.

  • I'm definitely interested in getting some answers about the actual Ruby code, so I'll post it in StackOverflow. If I'm later interested in finding answers for a language-agnostic pseudo-code algorithm, I'll post another question in Computer Science.
    – user163250
    Apr 8, 2014 at 6:14

You must log in to answer this question.