A list is ordered from smaller to largest when a sort is
called. Which sort would take the shortest time to execute?

Answer Posted / sathyanarayana

Yes, its insertion sort. For a sorted array, it takes just
O(n) time. iTs mere traversal of an array as it is already
sorted. In the case of quick sort, it boils down to O(n^2)
in the case of sorted array.

Is This Answer Correct ?    5 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can we store null in arraylist?

649


Explain the difference between a list and array.

723


Explain the expression trees?

780


What are the best data structure courses for gate preparation?

679


What is array in data structure with example?

673


What do you mean by data types?

712


How do you sort an array in descending order?

674


Why is an array homogeneous?

631


What is different between array and list?

704


What is an ordered map?

676


What is worst case complexity algorithm?

677


What is difference between hashmap and linkedhashmap?

632


Define an algorithm. What are the properties of an algorithm? What are the types of algorithms?

709


What is collections singletonlist?

668


Which interfaces are implemented by concurrentskiplistset?

661