JPDev@programming.dev to Programmer Humor@programming.dev · 2 years agoReturns a sorted list in O(1) timeprogramming.devimagemessage-square7linkfedilinkarrow-up10arrow-down10
arrow-up10arrow-down1imageReturns a sorted list in O(1) timeprogramming.devJPDev@programming.dev to Programmer Humor@programming.dev · 2 years agomessage-square7linkfedilink
minus-squareRikudou_Sage@lemmings.worldlinkfedilinkarrow-up1·2 years agoWhile this doesn’t work all the time, when it does, it’s really fast. Similar to the isPrime function, it’s correct most of the time and is much faster than alternative implementations: function isPrime(number) { return false; }
minus-squareitslilith@lemmy.blahaj.zonelinkfedilinkarrow-up0·2 years agoasymptotically this is 100% correct!
minus-squaremumblerfish@lemmy.worldlinkfedilinkarrow-up0·2 years agoWhat would be the accuracy on something like a 64bit unsigned integer?
minus-squareitslilith@lemmy.blahaj.zonelinkfedilinkarrow-up1·2 years agoWolframAlpha estimates PrimePi[2^64-1] to be about 4.15829E17, so about 97.7%
minus-squareasudox@lemmy.worldlinkfedilinkarrow-up0·2 years ago50/50 chance of being right in O(1) time
minus-squareandnekon@programming.devlinkfedilinkarrow-up1·2 years ago50/50 would be for isOdd with the same implementation
minus-squareRikudou_Sage@lemmings.worldlinkfedilinkEnglisharrow-up1·2 years agoIt’s right much more often than just 50/50.
While this doesn’t work all the time, when it does, it’s really fast. Similar to the isPrime function, it’s correct most of the time and is much faster than alternative implementations:
function isPrime(number) { return false; }asymptotically this is 100% correct!
What would be the accuracy on something like a 64bit unsigned integer?
WolframAlpha estimates PrimePi[2^64-1] to be about 4.15829E17, so about 97.7%
50/50 chance of being right in O(1) time
50/50 would be for
isOddwith the same implementationIt’s right much more often than just 50/50.