
Sort a in place by insertion and hand the whole array to report after every insertion, so the caller can watch the sorted prefix grow one slot at a time.
insertion_steps(a, 4, report) with a = {4, 3, 2, 1}step: 3 4 2 1
step: 2 3 4 1
step: 1 2 3 4
calls: 3insertion_steps(a, 4, report) with a = {1, 2, 3, 4}step: 1 2 3 4
step: 1 2 3 4
step: 1 2 3 4
calls: 3insertion_steps(a, 1, report) with a = {42}, then the buffercalls: 0
arr: 42insertion_steps(a, 3, report) with a = {3, 1, 2, 99}, then the bufferstep: 1 3 2
step: 1 2 3
calls: 2
arr: 1 2 3 99insertion_steps.c<stddef.h>defines size_t
Run the tests to grade your code
Sort a in place by insertion and hand the whole array to report after every insertion, so the caller can watch the sorted prefix grow one slot at a time.
insertion_steps(a, 4, report) with a = {4, 3, 2, 1}step: 3 4 2 1
step: 2 3 4 1
step: 1 2 3 4
calls: 3insertion_steps(a, 4, report) with a = {1, 2, 3, 4}step: 1 2 3 4
step: 1 2 3 4
step: 1 2 3 4
calls: 3insertion_steps(a, 1, report) with a = {42}, then the buffercalls: 0
arr: 42insertion_steps(a, 3, report) with a = {3, 1, 2, 99}, then the bufferstep: 1 3 2
step: 1 2 3
calls: 2
arr: 1 2 3 99insertion_steps.c<stddef.h>defines size_t
Run the tests to grade your code
Memory will appear here