hallo allerseits!
meine binäre Suche bockt (=> Stack Overflow). Sieht jemand den Fehler?
meine binäre Suche bockt (=> Stack Overflow). Sieht jemand den Fehler?
Code:
// zahl ist die gesuchte Zahl, l steht für low, h für high
public int binaereSuche(int zahl, int l, int h)
{
int mid = (l + h)/2;
if(mid == zahl)
return mid;
if(zahl < mid)
{
binaereSuche( zahl, l, mid-1);
}
if(zahl > mid)
{
binaereSuche(zahl, mid + 1, h);
}
return -1;
}