@[email protected] to Programmer [email protected] • 10 months agoReturns a sorted list in O(1) timeprogramming.devimagemessage-square27fedilinkarrow-up1279arrow-down115
arrow-up1264arrow-down1imageReturns a sorted list in O(1) timeprogramming.dev@[email protected] to Programmer [email protected] • 10 months agomessage-square27fedilink
minus-square@[email protected]linkfedilink11•10 months agoyou can make it sort the first k elements and it will still be O(1). Set k high enough and it might even be useful
minus-square@[email protected]linkfedilink5•10 months agoI set k to 50,000,000,000… that’s more items than my shitty computer can fit in memory (including swsp) but I am now happy to celebrate my O(1) algorithm.
minus-squareKubeRootlinkfedilink1•10 months agoBy that logic, any sorting implementation is O(1), as the indexing variable/address type has limited size
you can make it sort the first k elements and it will still be O(1). Set k high enough and it might even be useful
I set k to 50,000,000,000… that’s more items than my shitty computer can fit in memory (including swsp) but I am now happy to celebrate my O(1) algorithm.
By that logic, any sorting implementation is O(1), as the indexing variable/address type has limited size