5 ms·
It's not sorting though, you don't get closer to the desired order and there's no guaranteed bound on termination.
by pbhjpbhj 8y ago
It's not sorting though, you don't get closer to the desired order and there's no guaranteed bound on termination.
- benj111 8y agoYou kind of do get closer, every roll of the dice increases your chance of getting a 6. Agreed theres no guaranteed bound, that's my basis for suggesting it as worst.
- daveFNbuck 8y agoYour expected number of rolls until a 6 doesn't decrease with each roll. The same is true for this algorithm. If you run this algorithm and it has an expected 10 days runtime, you still have an expected 10 days left after 5 days of failure. The worstsort in the post has a much worse expected runtime than the sort you described. You could make the bound not guaranteed by randomly deciding whether to throw out the result and start over at the end.
- benj111 8y agoIf I roll a die the chances are 1 in 6 yes, but every throw is another bite of the cherry. If I throw the die 10 times, the chances of one of those throws being a 6 is greater than 1 in 6. The same with this 'sorting' algorithm. Yes you could add a random element to any sorting algorithm to make it slower. I suppose you could argue with my algorithm, the primary purpose of the random wasn't to slow the algorithm down, the algorithm would totally break! I'm not sure it even matters though. My primary point was that a random algorithm can be worse than just a slow algorithm. With Worstsort, you can be fairly certain that the heat death of the universe will interupt you. My algorithm you don't know, it might be instant, it might never finish. More concretely, do you want a game that runs at a steady 30fps, or a game that goes from 5fps to 30000fps, with an average of 60fps ?
- zbentley 8y agoThat's not accurate: https://en.wikipedia.org/wiki/Gambler%27s_fallacy https://en.wikipedia.org/wiki/Gambler%27s_fallacy
- benj111 8y agoGamblers fallacy is me rolling a die 10 times and so expecting the 11th time to be anything other than a 1 in 6 chance. That isn't what I'm saying. I'm saying if you roll a die 10 times, the chance of any one of those rolls being 6 is greater than 1 in 6. It is statistically likely if you roll a die 10 times, that you will roll a 6 at least once.
- daveFNbuck 8y agoThat's not the same thing as making progress though. You never get closer to rolling a 6.
- benj111 8y agoI said "kind of", because there isn't a direct link no. But my chances still increase. If I roll that die once, I know my chances of rolling a 6 are poor, if I roll it 10 times the odds would be better, a million times almost certain. If my chances of success are steadily increasing, why is that not progress? (especially for an algorithm based solely on chance).
- daveFNbuck 8y agoYour chances aren't steadily increasing. The chance you finish within a week is higher than the chance you finish within a day, but your chance is no higher after a day than before it. Consider an alternative algorithm based solely on chance. Pick an element uniformly at random and if it's larger than the element after it, swap them. This algorithm has progress, as the array becomes monotonically more sorted over time, decreasing the expected amount of time until the algorithm is done. This is what it looks like to make progress. Your algorithm does not have that feature.