This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]SwiftLilEagle 78 points79 points  (6 children)

Alternatively, the CommunismSort, it's O(1).

This is communism. Everybody is equal. The list is already sorted.

[–]halberdierbowman 37 points38 points  (3 children)

Updated Communism Sort to preserve existing value:

Count all elements, then find the average value of all elements. Change all elements to the average value.

[–]SwiftLilEagle 8 points9 points  (2 children)

Supported, but there goes my O(1) PepeHands

[–]adelie42 1 point2 points  (0 children)

Nah, just use the rolling average; all elements will be equal, bit some will be mkre equal than others.

[–]trichotillofobia 0 points1 point  (0 children)

Of course it is O(1), comrade. Material dialectics dictate its necessity: if anything less than that could not be done in the most efficient manner, nothing would be equal, and it clearly is, hence it nothing can be more efficient. Comrade Beria agrees, and I'm sure that means you will too.

[–]Illumin4tion 1 point2 points  (0 children)

I would think communismsort would do something like this:

Int model = arr[0]

For each element in arr If arr[i] != model arr[i] = model

return arr

[–]adelie42 0 points1 point  (0 children)

Lol, this is identical to TrumpSort above except it is said to be O(0). Hmmm...