cm0002@lemmy.world to Programmer Humor@programming.dev · 9 days agotimeoutSortlemmy.mlimagemessage-square36fedilinkarrow-up1481arrow-down14cross-posted to: [email protected]
arrow-up1477arrow-down1imagetimeoutSortlemmy.mlcm0002@lemmy.world to Programmer Humor@programming.dev · 9 days agomessage-square36fedilinkcross-posted to: [email protected]
minus-squareJankatarch@lemmy.worldlinkfedilinkarrow-up1·edit-21 day 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.