1

I was reviewing the big O cheatsheet at http://bigocheatsheet.com/ and ran into some listings under sort that I do not understand.

Runtimes are color coded, green being better than yellow. There are cases where Ω(N) is color coded better than Ω(N+K) and even Ω(NK). An example is bubble sort best case vs counting sort best case.

Assuming these are not mislabeled, can someone please explain why Ω(N+K) is better than Ω(N)?

  • 1
    per my reading examples at this cheatsheet you refer to (bubble and counting sort best case) show Omega (Ω) not Big-O, do you understand the difference? – gnat Sep 16 '16 at 20:25
  • 1
    @gnat Does it really matter? Best case, worst case, average case, upper bounds, tight bounds... I changed my title to match. If it does matter, then please do answer the question and explain why. – cocogorilla Sep 16 '16 at 20:31
3

I think you simply found a mistake in the website.

The N+K and NK entries should be coded in yellow, not green. As far as I can tell, every single other entry strictly follows the chart at the top.

Today you learned that just because it's written on some website (or book, or newspaper), it's not necessarily correct or true. This is an important lesson to keep in mind at all times.

| improve this answer | |
  • Interestingly, space complexity for radix sort has a correctly yellow O(n+k). – 8bittree Sep 16 '16 at 21:00
  • ROFL... I very seriously assumed there was some deep mathematical computer science nuance I'd need the experts to explain to me. I can't believe its just an error. So I take it N is better than N+K or NK? – cocogorilla Sep 16 '16 at 21:06
  • 1
    When it comes to big-O/big-Omega/big-Theta, constants do not matter by definition. If you can get the actual runtime (as in number of comparisons or iterations or swaps) as a function, then yes N < N+K < NK for most N and K. But it's important to remember that the big-O notation implicitly hides constants to show the most significant term in the runtime. – Andrew Sep 16 '16 at 21:42
  • 1
    @AndrewPiliser It should be noted that K here is not a constant and, depending on the exact implementation of the algorithm, could have more influence on big-O/Ω/Θ than N for all values of N. – 8bittree Sep 19 '16 at 13:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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