Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

How to use the insertionSort Algorithm in python 3? Can anyone show me how this

ID: 3734360 • Letter: H

Question

How to use the insertionSort Algorithm in python 3? Can anyone show me how this is setup in python and linked to the list and then implemented to get the values in the chart?

Thank you

1. def insertionSort (nums): for i in range(1, len(nums)): 2. 4 6 save nums[i] while j > 0 and nums [j - 1] > save : nums[j]-nums[j - 1] nums[j]- save In order to have a real understanding of how the code works, we need to follow its execution. Show the step-by-step execution of the code above where the parameter data is as follows index 0 4 data 3 2 6 A21. Fill in the following table as you execute the code. data 4 save 3 6

Explanation / Answer

i = 1, j = 1, save = 9, list = [3, 9, 2, 7, 4, 8, 1, 6, 5]
i = 2, j = 0, save = 2, list = [2, 3, 9, 7, 4, 8, 1, 6, 5]
i = 3, j = 2, save = 7, list = [2, 3, 7, 9, 4, 8, 1, 6, 5]
i = 4, j = 2, save = 4, list = [2, 3, 4, 7, 9, 8, 1, 6, 5]
i = 5, j = 4, save = 8, list = [2, 3, 4, 7, 8, 9, 1, 6, 5]
i = 6, j = 0, save = 1, list = [1, 2, 3, 4, 7, 8, 9, 6, 5]
i = 7, j = 4, save = 6, list = [1, 2, 3, 4, 6, 7, 8, 9, 5]
i = 8, j = 4, save = 5, list = [1, 2, 3, 4, 5, 6, 7, 8, 9]

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote