Better than \(O(n!)\)?

Computer Science Level pending

Given below is sorting algorithm(sort(l)).

1
2
3
4
5
6
7
8
import random
import time

def sort(l):
    while is_not_sorted(l):
        time.sleep(60*60)  # Wait one hour
        random.shuffle(l)  # Shuffle the list
    return l

Given an array l, your task is to find the expected number of hours \(Q\), it takes for the sorting algorithm to finish sorting l?

For each of the arrays in this file, find \(Q\) for each array and input the sum of the \(Q\)s as your answer.

×

Problem Loading...

Note Loading...

Set Loading...