JPDev@programming.dev to Programmer Humor@programming.dev · 8 months agoReturns a sorted list in O(1) timeprogramming.devimagemessage-square20fedilinkarrow-up1271
arrow-up1258imageReturns a sorted list in O(1) timeprogramming.devJPDev@programming.dev to Programmer Humor@programming.dev · 8 months agomessage-square20fedilink
minus-squaremcmodknower@programming.devlinkfedilinkarrow-up8·8 months agoyou can even have a case where you return the first element of the list if the list is not empty, and it will still be O(1).
minus-squaremurtaza64@programming.devlinkfedilinkarrow-up10·8 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-squareKubeRoot@discuss.tchncs.delinkfedilinkarrow-up2arrow-down1·8 months agoBy that logic, any sorting implementation is O(1), as the indexing variable/address type has limited size
you can even have a case where you return the first element of the list if the list is not empty, and it will still be O(1).
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
By that logic, any sorting implementation is O(1), as the indexing variable/address type has limited size