What is the average case time complexity of gnome sort?

What is the average case time complexity of gnome sort?
A. O(n)
B. O(n$^{2}$)
C. O(n log n)
D. O(log n)
 
Answer: b
Explanation: In gnome sort the loop has to take one step backwards every time any adjacent pair of elements is out of place which causes it to have time complexity of O(n$^{2}$) on an average.
 

Tìm kiếm

Back
Top