![]() |
Lesson | Selection Animation | Insertion Animation |
Student Toolkit - Insertion Sort Simulation
Insertion Sort animation to help visualize the sorting algorithm; meant to pair with student_toolkit sorting part 1 team teach lesson
Insertion Sort Visualization
void insertion_sort(int A[], int n) {
for (int i = 1; i < n; i++) {
int key = A[i];
int j = i - 1;
while (j >= 0 && A[j] > key) {
A[j + 1] = A[j];
j--;
}
A[j + 1] = key;
}
}