Insertion Sort
Insertion Sort
A Level Only – You are required to know how it works and be able to write Code / Pseudocode for the algorithm
Python Tutorial
Python Tutorial Video
Python Code
Python code
l = [7,11,3,1,2,5,6,9] def insertion_sort(l): for outer_index in range(1,len(l)): current_item = l[outer_index] inner_index = outer_index while inner_index > 0 and l[inner_index-1] > current_item: l[inner_index] = l[inner_index-1] inner_index -= 1 l[inner_index] = current_item insertion_sort(l) print(l)
Pseudocode
Pseudocode
Resources
Student Walkthrough Google Sheets Example
Insertion Sort Python Animation
Go to File > Make a copy so that you can edit the sheet and practice the algorithm.