I was trying to code the following Insertion Sort
problem: 362C I also saw the tutorial but, i still didn't understand the given expression on the tutorial. For a given example:
input:
5
4 0 3 1 2
Output:
3 2
appropriate pairs are (0, 3) and (0, 4) in the tutorial the solution says:
old - 2 * (di, ai + dj, aj - di, aj - dj, ai) - 1
So can anyone please explain, how this expression solves the problem? So please please help. Thanks