cm0002@lemmy.world to Programmer Humor@programming.dev · 18 days agotimeoutSortlemmy.mlimagemessage-square13linkfedilinkarrow-up17arrow-down10cross-posted to: programmerhumor@lemmy.ml
arrow-up17arrow-down1imagetimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 18 days agomessage-square13linkfedilinkcross-posted to: programmerhumor@lemmy.ml
minus-squareJankatarch@lemmy.worldlinkfedilinkarrow-up1·10 days 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.