182k views
1 vote
assume that you want to sort an array have 100000 elements which algorithm (insert sort algorithm or quick sort algorithm) is the best option ? why?

User Itun
by
4.9k points

1 Answer

4 votes

Answer:

Quick Sort.

Step-by-step explanation:

Quick Sort will be best suited for an array having 100000 elements instead of the insertion sort algorithm because as we know the average time complexity of quick sort is O(NlogN) and for insertion sort is O(n^2).The sorting totally depends upon the pivot that is being selected in quick sort.

While insertion sort is best suited for arrays that are already sorted it takes O(n) time in those cases.

Since the array that we have is very large and so we need an algorithm that can sort the array faster than the other sorting algorithms.Quick Sort is also inplace and does not requires extra space to do the sorting.

User Max Bumaye
by
4.6k points