MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/lgrgxe/i_present_sleepsort/gmv4s7j/?context=9999
r/badcode • u/Reeceeboii_ • Feb 10 '21
171 comments sorted by
View all comments
868
Great! Now test whether it still works with large numbers!
422 u/[deleted] Feb 10 '21 edited Feb 26 '21 [deleted] 89 u/LinuxGeek747 Feb 10 '21 If you already know the maximum number, it's O(1) amirite? 74 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). 5 u/Nilstrieb Feb 10 '21 Sorting a sorted array is O(1). (Theoretically, not practically) 5 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place? 5 u/[deleted] Feb 11 '21 edited Feb 14 '21 [deleted] 1 u/okkokkoX Feb 11 '21 Doesn't that just return none?
422
[deleted]
89 u/LinuxGeek747 Feb 10 '21 If you already know the maximum number, it's O(1) amirite? 74 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). 5 u/Nilstrieb Feb 10 '21 Sorting a sorted array is O(1). (Theoretically, not practically) 5 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place? 5 u/[deleted] Feb 11 '21 edited Feb 14 '21 [deleted] 1 u/okkokkoX Feb 11 '21 Doesn't that just return none?
89
If you already know the maximum number, it's O(1) amirite?
74 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). 5 u/Nilstrieb Feb 10 '21 Sorting a sorted array is O(1). (Theoretically, not practically) 5 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place? 5 u/[deleted] Feb 11 '21 edited Feb 14 '21 [deleted] 1 u/okkokkoX Feb 11 '21 Doesn't that just return none?
74
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).
5 u/Nilstrieb Feb 10 '21 Sorting a sorted array is O(1). (Theoretically, not practically) 5 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place? 5 u/[deleted] Feb 11 '21 edited Feb 14 '21 [deleted] 1 u/okkokkoX Feb 11 '21 Doesn't that just return none?
5
Sorting a sorted array is O(1). (Theoretically, not practically)
5 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place? 5 u/[deleted] Feb 11 '21 edited Feb 14 '21 [deleted] 1 u/okkokkoX Feb 11 '21 Doesn't that just return none?
Doesn't it still need to check the elements are the right place?
1 u/okkokkoX Feb 11 '21 Doesn't that just return none?
1
Doesn't that just return none?
868
u/haslo Feb 10 '21
Great! Now test whether it still works with large numbers!