sorting a million 32 bit integers

best way to do it?

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 24135 Views - Last Post: 06 July 2012 - 03:05 PM

#16 anonymous26   User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: sorting a million 32 bit integers

Posted 06 December 2010 - 10:02 AM

View Postmacosxnerd101, on 06 December 2010 - 03:42 PM, said:

O(n) is worst case for memory usage, not runtime. Worst case runtime is O(n log(n)).

Yes, quite right. I did say a 'quick look' and I have more important things to remember than merge sort efficiency.

Anyway, any better suggestions on Merge Sort?

This post has been edited by ButchDean: 06 December 2010 - 10:01 AM

Was This Post Helpful? -1
  • +
  • -

#17 Nikitin   User is offline

  • D.I.C Regular

Reputation: 56
  • View blog
  • Posts: 264
  • Joined: 02-August 10

Re: sorting a million 32 bit integers

Posted 06 December 2010 - 02:11 PM

View PostButchDean, on 05 December 2010 - 04:41 PM, said:

Merge Sort immediately came to my mind. With a a million 32-bit integers you cannot be looking at anything worse than O(n). That would be insane!

I know, merge sort took a whopping 2 seconds to sort a million 32-bit integers on my old Pentium! Oh the humanity!

View PostButchDean, on 06 December 2010 - 09:37 AM, said:

Just glancing at Wikipedia it has an average case of O(n log n) with a worse case of O(n), hence my suggestion of its use. :)

Quote

Yes, quite right. I did say a 'quick look' and I have more important things to remember than merge sort efficiency.


Like remembering what big-O is, and how it works?

=========

Sorry, I'm under a lot of stress this week.
Was This Post Helpful? 0
  • +
  • -

#18 Guest_Parth*


Reputation:

Re: sorting a million 32 bit integers

Posted 08 December 2010 - 08:28 PM

View PostButchDean, on 06 December 2010 - 05:50 AM, said:

View PostParth, on 06 December 2010 - 08:34 AM, said:

View PostButchDean, on 05 December 2010 - 03:41 PM, said:

Merge Sort immediately came to my mind. With a a million 32-bit integers you cannot be looking at anything worse than O(n). That would be insane!



Mergesort is not O(n)

I didn't say it was. Read again, I said that "Merge Sort immediately comes to mind but you cannot be looking at anything worse than O(n)." Nothing about Merge Sort itself being O(n).


Maah bad Butchie! :) Forgive and forget :)
Was This Post Helpful? 0

#19 anonymous26   User is offline

  • D.I.C Lover

Reputation: 2
  • View blog
  • Posts: 3,638
  • Joined: 26-November 10

Re: sorting a million 32 bit integers

Posted 08 December 2010 - 08:30 PM

No, no I won't forget! :gun_bandana:

:bananaman:
Was This Post Helpful? 0
  • +
  • -

#20 tek1   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 06-July 12

Re: sorting a million 32 bit integers

Posted 06 July 2012 - 03:05 PM

View PostButchDean, on 06 December 2010 - 09:37 AM, said:

Just glancing at Wikipedia it has an average case of O(n log n) with a worse case of O(n), hence my suggestion of its use. :)

Ignoring the fact that you had mistaken worst-case space for worst-case time, your deduction wouldn't make sense because the average case -- O(n log n) -- is greater than what you had believed to be the worst case -- O(n). (The worst case can't be less than the average case)
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2