stalin-sort
stalin-sort copied to clipboard
So 3, 4, 5, 6, 7, 8 and 9 are out of order in this array? [1, 2, 50, 3, 4, 5, 6, 7, 8, 9]
Any element which is out of order is eliminated
The 50 is the asshole here, why did the others have to die? Whyyy god whyy?
It's a subtle representation of how the many isms of the world and its tyrannical enforcers toy with human beings by subjecting them to arbitrary rules that ultimately result in senseless suffering.
Indeed, if we have largest element at the beginning, any other elements will be removed. The approach to tackle such worst case condition is to randomly shuffle the array before using Stalin sort, which still gives O(n).
Listen lads, the 50 was obviously in that position for a good reason. If you think the Supreme Soviet might have made a mistake then by all means queue up in that line over there. Don't worry about the order.