in

Sorting with O(n) efficiency

Sorting with O(n) efficiency | array-memes, sorting-memes | ProgrammerHumor.io
array-memes, sorting-memes | ProgrammerHumor.io

Content

According to quantum theory, every possible universe exists, so there is a universe where the array is already sorted. We can make use of this by destroying every universe where this is not the case. Efficiency: O(n) def is sorted(array): for i in range(len (array) -1) : if arrayi arrayi1: return False return True def quantumbogo sort (array) : if is sorted(array): return array else: destroy universe() This is left as an exercise to the reader