gs gs122 Searching - Binary Search Iterative - Quiz No.1
gs gs122 Data Communication and Computer Network Quiz
This quiz belongs to book/course code gs gs122 Data Communication and Computer Network of gs organization. We have 268 quizzes available related to the book/course Data Communication and Computer Network. This quiz has a total of 10 multiple choice questions (MCQs) to prepare and belongs to topic Searching. NVAEducation wants its users to help them learn in an easy way. For that purpose, you are free to prepare online MCQs and quizzes.
NVAEducation also facilitates users to contribute in online competitions with other students to make a challenging situation to learn in a creative way. You can create one to one, and group competition on an topic of a book/course code. Also on NVAEducation you can get certifications by passing the online quiz test.
public static int recursive(int arr[], int low, int high, int key) { int mid = low + (high - low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { return recursive(arr,mid+1,high,key); } else { return recursive(arr,low,mid-1,key); } }
public static int recursive(int arr[], int low, int high, int key) { int mid = low + (high + low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { return recursive(arr,mid-1,high,key); } else { return recursive(arr,low,mid+1,key); } }
public static int recursive(int arr[], int low, int high, int key) { int mid = low + (high - low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { return recursive(arr,mid,high,key); } else { return recursive(arr,low,mid-1,key); } }
public static int recursive(int arr[], int low, int high, int key) { int mid = low + ((high - low)/2)+1; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { return recursive(arr,mid,high,key); } else { return recursive(arr,low,mid-1,key); } }
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high + low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid - 1; } else { high = mid + 1; } } return -1; }
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high - low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid + 1; } else { high = mid - 1; } } return -1; }
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high + low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid + 1; } else { high = mid - 1; } } return -1; }
public static int iterative(int arr[], int key) { int low = 0; int mid = 0; int high = arr.length-1; while(low <= high) { mid = low + (high - low)/2; if(arr[mid] == key) { return mid; } else if(arr[mid] < key) { low = mid - 1; } else { high = mid + 1; } } return -1; }