if i is even that means till now we have even number of elements so we store result in 0 th indexed row
else { while ( ++ j <= W ) { if ( wt [ i ] <= j ) { mat [ 0 , j ] = Math . Max ( val [ i ] + mat [ 1 , j - wt [ i ] ] , mat [ 1 , j ] ) ; } else { mat [ 0 , j ] = mat [ 1 , j ] ; } } } i ++ ; }