cm0002@lemmy.world to Programmer Humor@programming.dev · 2 months agotimeoutSortimagemessage-square36linkfedilinkarrow-up1481arrow-down13cross-posted to: programmerhumor@lemmy.ml
arrow-up1478arrow-down1imagetimeoutSortcm0002@lemmy.world to Programmer Humor@programming.dev · 2 months agomessage-square36linkfedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squareJankatarch@lemmy.worldlinkfedilinkarrow-up1·edit-22 months agoThis algorithm takes K seconds where K is the value of the greatest element. This means if you just multiply everything by -1 it will take negative time to sort. Then you can simply unmultiply and read from end to beginning from now on. This is faster than having it presorted.
This algorithm takes K seconds where K is the value of the greatest element.
This means if you just multiply everything by -1 it will take negative time to sort.
Then you can simply unmultiply and read from end to beginning from now on.
This is faster than having it presorted.