You are required to investigate the number of comparisons that take place during the execution of an insertion sort. Given a list of ?N unsorted integers, use insertion sort to count the number of...


You are required to investigate the number of comparisons that take place during the execution of an insertion sort. Given a list of ?N unsorted integers, use insertion sort to count the number of comparisons that it takes to arrive at the sorted list. Your insertion sort should execute from left to right.



Function specifications



Argument(s):




  • integers (list) →→ a list of unsorted integers.



Return:




  • comparisons (int) →→ return the number of comparisons made to arrive at the sorted list.



### START FUNCTION
def insertion_sort(integers):


### END FUNCTION




integers = [15,  1,  2, 16, 12, 16,  9,  2,  0, 11]
insertion_sort(integers.copy())



Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here