Time complexity of sleep sort can be approximated to be ___________

Tâm Tây

New member
Time complexity of sleep sort can be approximated to be ___________
A. O(n + max(input))
B. O(n$^{2}$)
C. O(n log n + max(input))
D. O(n log n)
 
Answer: c
Explanation: As the sleep() function creates multiple threads by using priority queue which takes n log n time for insertion. Also the output is obtained when all the elements wake up. This time is proportional to the max(input). So its time complexity is approximately O(n log n + max(input)).
 

Tìm kiếm

Back
Top