For a target cell x, we need to find the minimum of:
this + substitution | this + deletion
--------------------+----------------
this + insertion | x
From top-left is when we haven't processed to either value yet, so we must process both at the same time, thus it's a substitution.
From left is when we haven't processed the target value yet, so it's insertion.
From top is when we haven't processed the source value yet, so it's deletion.
To store the values separately, you'll need a 3D array:
array[targetSize+1][inputSize+1][3]
Then, for each of the 3 previous cells, you add 1 substitution, deletion or insertion (as indicated above), then calculate the total cost based on the number of substitutions, deletions and insertions, and find the minimum of the 3 costs. Then copy the values from the cell giving the minimum to the current cell (with the 1 operation added).
So, for:
0/1/0|0/2/0
-----+-----
0/0/1| x
Let's assume a cost of 1 for each operation.
We calculate:
0/1/0
+ 1 substitution = 0/1/1
, cost = 2
0/0/1
+ 1 insertion = 0/1/1
, cost = 2
0/2/0
+ 1 deletion = 1/2/0
, cost = 3
Then we pick either of the cost 2's and put 0/1/1
into the new cell.
I hope that helps.