hello everyone i'm trying to create algoithm for binary search in multi dimensinal array
i have done it on one dimensinal and changed some things but still there is something wrong
here's the code i hope you can help
public static void binarysearch(int [][] numbers,int searchedvalue)
{
int lowrow = 0;
int lowcolumn = 0;
int highcolumn = numbers.length;
int highrow = numbers.length;
int result;
int midrow = 0 ,midcolumn = 0;
while (lowrow < highrow)
{
midrow = lowrow + highrow / 2;
midcolumn = lowcolumn + highcolumn / 2;
if(numbers[midrow][midcolumn] == searchedvalue)
{
result = 1;
if (result == 1)
{
System.out.println(searchedvalue + " has been found in index " + midrow + midcolumn);
}
}
else if (numbers[midrow][midcolumn] < searchedvalue)
{
lowrow = midrow + 1;
lowcolumn = midcolumn + 1;
}
else
{
highrow = midrow;
highcolumn = midcolumn;
}
}
result = 0;
if (result == 0)
{
System.out.println(searchedvalue + " has not been found in the array");
}
wInline Code Example Here