Solution for the insertion sort analysis problem