Choose The Appropriate Code That Does Binary Search Using #466
Choose the appropriate code that does binary search using recursion.
This multiple choice question (MCQ) is related to the book/course gs gs122 Data Communication and Computer Network. It can also be found in gs gs122 Searching - Binary Search Iterative - Quiz No.1.
Choose the appropriate code that does binary search using recursion.
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); } }
Similar question(s) are as followings:
Online Quizzes of gs122 Data Communication and Computer Network
Sorting - Insertion Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - Insertion Sort - Quiz No.3
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - LSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.1
gs gs122 Data Communication and Computer Network
Online Quizzes
Sorting - MSD Radix Sort - Quiz No.2
gs gs122 Data Communication and Computer Network
Online Quizzes