Sort number of comparisons using insertion sort


Assignment:

Question 1. Suppose that L is a list is of length n and it is sorted using insertion sort. If Lis already sorted in the reverse order, show that the number of comparisons is (1/2)(n2 - n) and the number of item assignments is (1/2)(n2 +3n) - 2.

Question 2. Suppose that L is a list is of length n and it is sorted using insertion sort. If Lis already sorted, show that the number of comparisons is (n - 1) and the number of item assignments is 0.

Solution Preview :

Prepared by a verified Expert
Data Structure & Algorithms: Sort number of comparisons using insertion sort
Reference No:- TGS01826692

Now Priced at $30 (50% Discount)

Recommended (90%)

Rated (4.3/5)