cm0002@lemmy.world to Programmer Humor@programming.dev · 13 days agotimeoutSortimagemessage-square36linkfedilinkarrow-up1475arrow-down14
arrow-up1471arrow-down1imagetimeoutSortcm0002@lemmy.world to Programmer Humor@programming.dev · 13 days agomessage-square36linkfedilink
minus-squareJankatarch@lemmy.worldlinkfedilinkarrow-up1·5 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.