Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Concepts

Authors: David M Kroenke, David J Auer

6th Edition

0132742926, 978-0132742924

More Books

Students also viewed these Databases questions

Question

Write a Python program to check an input number is prime or not.

Answered: 1 week ago

Question

Write a program to check an input year is leap or not.

Answered: 1 week ago

Question

What is the most important part of any HCM Project Map and why?

Answered: 1 week ago