This flashcard is just one of a free flashcard set. See all flashcards!
5
Binäre Suche (rekursiv)
static boolean binaer(int [] array, int unter, int oben, int key){
if (unten > oben){
return false;
} else {
int mitte = (unten + oben)/2;
if(array[mitte]==key){
return true;
} else if(array[mitte] < key){
return binaer(array, mitte +1, oben, key)
} else{
return binaer (array, unter, mitte - 1, key)
}
}
if (unten > oben){
return false;
} else {
int mitte = (unten + oben)/2;
if(array[mitte]==key){
return true;
} else if(array[mitte] < key){
return binaer(array, mitte +1, oben, key)
} else{
return binaer (array, unter, mitte - 1, key)
}
}
Flashcard info:
Author: hristiana86
Main topic: Informatik
School / Univ.: HS
City: Mannheim
Published: 14.06.2010