1.

What is the advantage of library sort over insertion sort?(a) Library sort has a better average time complexity(b) Library sort has a better space complexity(c) Library sort has better best case time complexity(d) Library has better worst case time complexityThis question was posed to me in an online interview.This key question is from Sorting topic in division Sorting of Data Structures & Algorithms II

Answer»

Correct choice is (a) Library sort has a BETTER average time complexity

Best explanation: Library sort has a better average time complexity as COMPARED to insertion sort because it USES binary search for finding the index where the ELEMENT has to be inserted in the sorted ARRAY. This makes the process faster.



Discussion

No Comment Found

Related InterviewSolutions