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 dynamic array how it is created?

496


What is the use of placement new?

590


What are data and data types?

509


What do you mean by balanced trees?

544


What is the difference between hashset and hashmap?

535






Model a data structure for a DFA that takes an event as parameter and performs a desired action.

702


Define adjacent nodes?

563


Is an arraylist a vector?

499


Is treeset thread safe?

495


List out a few of the applications that make use of Multilinked Structures?

730


What is the purpose of sorting algorithms?

510


Is array a data structure?

506


Define threaded binary tree. Explain its common uses

501


Two linked lists are given, find out the sum of them without altering the linked list?

561


Why is selection sort used?

496