took a array of 2 elements let's suppose [3,1]
now you have to sort it in ascending order
import random
arr = [2, 3] if random.randint(0, 1) == 1: # 50% chance to swap (1 out of 0 or 1) arr[0], arr[1] = arr[1], arr[0] print(arr) it will swap elements in O(1)
and it's sorting so, it's best case is O(1) so, worst case is O(n!)
so actually their is a chance that in first iteration
we will get sorted array
but chances and probablity are 50%
so can we say that O(1) sorting algorithm exist



