The home where you level up

Save my spot

Thanos Sort

Term side of the Card.
Topic: Inefficient Sorting Algorithms
Unit title: Thanos Sort
Categories: Algorithm, Concept
Explanation side of the Card

Explanation: The humorous sorting algorithm that randomly deletes half of the elements until only a sorted list remains. Inspired by the fictional character Thanos' idea of random selection.

Interview questions

Is Thanos sort a real sorting algorithm?

No, it is a joke. It throws away data, so the output is not a sorted version of the input.

Does Thanos sort always finish?

Yes, the list keeps halving, and one element is always sorted. The total work is O(n), because each round checks a list half the previous size.

Thanos sort vs Stalin sort: what is the difference?

Thanos sort deletes a random half each round. Stalin sort deletes every element smaller than the one before it in one pass.

The home where you level up

Daily 3-minute lessons to understand your AI's code.

No spam — just launch news.
Unsubscribe anytime. · Privacy Policy

Analytics cookiesWe'd like to use analytics cookies to see which pages are useful. They're set only if you accept. Privacy Policy