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

What is a weighted graph?

656


How is a hashset implemented?

558


Why is treeset sorted?

611


What is the difference between for and foreach loop?

554


List the basic operations carried out in a linked list?

733






Draw the B-tree of order 3 created by inserting the following data arriving in sequence – 92 24 6 7 11 8 22 4 5 16 19 20 78

1228


What is the difference between adt and data structure?

542


What is the top of a stack?

615


What are linked lists used for?

621


If we try to add duplicate key to the hashmap, what will happen?

576


Define distributed query and linked server?

626


What is the difference between array and stack in data structures?

580


Is array a data type?

562


Why is quicksort unstable?

578


Can array store heterogeneous data?

527