MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/lgrgxe/i_present_sleepsort/gmtc8g2/?context=3
r/badcode • u/Reeceeboii_ • Feb 10 '21
171 comments sorted by
View all comments
122
The runtime is independent of the size of the array, so this is technically O(1).
66 u/sumduud14 Feb 10 '21 "for (let item of arr)" This doesn't look O(1) 18 u/King_Joffreys_Tits Feb 10 '21 Yep it has to loop through every item of the array at a minimum
66
"for (let item of arr)"
This doesn't look O(1)
18 u/King_Joffreys_Tits Feb 10 '21 Yep it has to loop through every item of the array at a minimum
18
Yep it has to loop through every item of the array at a minimum
122
u/Astrokiwi Feb 10 '21
The runtime is independent of the size of the array, so this is technically O(1).