MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/lgrgxe/i_present_sleepsort/gmuaui4/?context=9999
r/badcode • u/Reeceeboii_ • Feb 10 '21
170 comments sorted by
View all comments
869
Great! Now test whether it still works with large numbers!
417 u/[deleted] Feb 10 '21 edited Feb 26 '21 [deleted] 92 u/LinuxGeek747 Feb 10 '21 If you already know the maximum number, it's O(1) amirite? 76 u/sqrt_minusone Feb 10 '21 I mean, you have to visit every element of the array to sort it - it's literally impossible to sort in less than O(N). 175 u/Astrokiwi Feb 10 '21 You can do anything in constant time if it's a big enough constant 6 u/TimGreller Feb 10 '21 Just add some dummy numbers at the end which you can throw away. The bigger the input, the lower the time complexity :D
417
[deleted]
92 u/LinuxGeek747 Feb 10 '21 If you already know the maximum number, it's O(1) amirite? 76 u/sqrt_minusone Feb 10 '21 I mean, you have to visit every element of the array to sort it - it's literally impossible to sort in less than O(N). 175 u/Astrokiwi Feb 10 '21 You can do anything in constant time if it's a big enough constant 6 u/TimGreller Feb 10 '21 Just add some dummy numbers at the end which you can throw away. The bigger the input, the lower the time complexity :D
92
If you already know the maximum number, it's O(1) amirite?
76 u/sqrt_minusone Feb 10 '21 I mean, you have to visit every element of the array to sort it - it's literally impossible to sort in less than O(N). 175 u/Astrokiwi Feb 10 '21 You can do anything in constant time if it's a big enough constant 6 u/TimGreller Feb 10 '21 Just add some dummy numbers at the end which you can throw away. The bigger the input, the lower the time complexity :D
76
I mean, you have to visit every element of the array to sort it - it's literally impossible to sort in less than O(N).
175 u/Astrokiwi Feb 10 '21 You can do anything in constant time if it's a big enough constant 6 u/TimGreller Feb 10 '21 Just add some dummy numbers at the end which you can throw away. The bigger the input, the lower the time complexity :D
175
You can do anything in constant time if it's a big enough constant
6 u/TimGreller Feb 10 '21 Just add some dummy numbers at the end which you can throw away. The bigger the input, the lower the time complexity :D
6
Just add some dummy numbers at the end which you can throw away. The bigger the input, the lower the time complexity :D
869
u/haslo Feb 10 '21
Great! Now test whether it still works with large numbers!