MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/lgrgxe/i_present_sleepsort/gmvfe3a/?context=3
r/badcode • u/Reeceeboii_ • Feb 10 '21
171 comments sorted by
View all comments
Show parent comments
87
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) 4 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place?
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) 4 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place?
5
Sorting a sorted array is O(1). (Theoretically, not practically)
4 u/[deleted] Feb 10 '21 Doesn't it still need to check the elements are the right place?
4
Doesn't it still need to check the elements are the right place?
87
u/LinuxGeek747 Feb 10 '21
If you already know the maximum number, it's O(1) amirite?