Which method runs faster for an array with all keys identical, basic selection sort or basic insertion sort?
Answers
Answered by
2
Explanation:
If all the keys are identical then bubble sort will do just a single sweep of the list without doing any exchanges so it would run in linear time. Insertion sort however, has to sweep the sorted list each time to determine where to insert each element so it would still run in quadratic time.
Similar questions