Question: Problem 1: Below is the Python Code for insertion sort: def insertion_sort(a): n = len(a) for i in range(1, n): j = i while (j

Problem 1:

Below is the Python Code for insertion sort:

def insertion_sort(a): n = len(a) for i in range(1, n): j = i while (j > 0) and (a[j]

It is being tested with the following Python list:

def main(): a = [5, 7, 12, 19, 21, 26,33,40,14,9,18,21,2] insertion_sort(a)

The Python list looks like the below when i=8 finishes execution and i turns to 9. ( See image below)

Problem 1: Below is the Python Code for insertion sort: def insertion_sort(a):

What does the list look like when i=9 finishes execution?

[]

What does the list look like when i=10 finishes execution?

[]

What does the list look like when i=11 finishes execution?

[]

def insertion_sort(a) a: : [5, 7, 12, 14, 19, 21, 26, 33, 40, 9, 18, 21, 21 n len (a) n: 13 for i in range(1, n): i: 9 while (j >0) and (aljl

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!