Last answered:

21 Oct 2020

Posted on:

23 May 2020


Insertion sort in python

In the search  and sort section in the python programming bootcamp I dont understand the insertion sort.  Below is the code. The part where I put astericks are the parts I dont understand 
Start your code here
Def insertion_sort(my_list)
n = len(my_list)
For I in range(1,n)
Value = my_list[1]
*** J = 1
While j > 0 and my_list[j-1] > value
My_list[j] = my_list[j-1]
J = j -1
My_list[j] = value ********
Return my_list
When the instructor was testing his code he used the bubble sort function instead of the insertion sort function. Is that meant to be so?.   Thank you   
1 answers ( 0 marked as helpful)
Posted on:

21 Oct 2020

Hi Chizom,  thanks for reaching out! You're not supposed to use bubble_sort() to test the insertion sort algorithm. You can now download the updated Notebook file from the lecture.   Best,  The 365 Team

Submit an answer