Given the following data 100 90 80 70 60 50 40 30 20 10 5 3

Given the following data:
100 90 80 70 60 50 40 30 20 10 5 3 2 1 0 -1
which method will be the best and which will be the worst to sort the above data. Explain your answer

Solution

Answer:

Insertion sort is the best for already sorted list. Quick sort will be the worst.

In Insertion sort you have to scan just once if array is already sorted and there will be no swap operation take place and in quick sort if you take first element as pivot then array will be devide in 2 parts first is 1 and 2nd part is (n-1) nd so on so time complexity will be n^2.

Given the following data: 100 90 80 70 60 50 40 30 20 10 5 3 2 1 0 -1 which method will be the best and which will be the worst to sort the above data. Explain

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site