say i have a two dimensional array a[512][512]. There is one more 2D array
b[512][512]. The algorithm is like this depending on value of a[i][j] i have compare b[j][k] with two of its neighbour.
This is a part of that algorithm
if(a[j][k]==0)
{
if(b[j][k]>=b[j][k+1] && b[j][k]>=b[j][k-1])
some code here
}
the problem is when k=0 b[j][k-1] will be b[j][0-1]=b[j][-1].
To handle this i have padded b[i][j] in such a way that b[j][-1] and b[-1][k] is zero for all j and k.
My question here is is it the right way to handle the negative indexes in array??
should there be any modification made in the code.
b[512][512]. The algorithm is like this depending on value of a[i][j] i have compare b[j][k] with two of its neighbour.
This is a part of that algorithm
if(a[j][k]==0)
{
if(b[j][k]>=b[j][k+1] && b[j][k]>=b[j][k-1])
some code here
}
the problem is when k=0 b[j][k-1] will be b[j][0-1]=b[j][-1].
To handle this i have padded b[i][j] in such a way that b[j][-1] and b[-1][k] is zero for all j and k.
My question here is is it the right way to handle the negative indexes in array??
should there be any modification made in the code.
Comment