What Is The Output Of The Following Codep Pre Langc #1806
What is the output of the following code?</p> <pre><code class="language-c"> #include<stdio.h> int recursive_binary_search(int *arr, int num, int lo, int hi) { if(lo > hi) return -1; int mid = (lo + hi)/2; if(arr[mid] == num) return mid; else if(arr[mid] < num) lo = mid + 1; else hi = mid - 1; return recursive_binary_search(arr, num, lo, hi); } int main() { int arr[8] = {0,0,0,0,3,5,6,7},num = 0,len = 8; int indx = recursive_binary_search(arr,num,0,len-1); printf("Index of %d is %d",num,indx); return 0; }</code></pre>
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 Recursion - Search an Element in an Array using Recursion - Quiz No.2.
What is the output of the following code?
#include<stdio.h> int recursive_binary_search(int *arr, int num, int lo, int hi) { if(lo > hi) return -1; int mid = (lo + hi)/2; if(arr[mid] == num) return mid; else if(arr[mid] < num) lo = mid + 1; else hi = mid - 1; return recursive_binary_search(arr, num, lo, hi); } int main() { int arr[8] = {0,0,0,0,3,5,6,7},num = 0,len = 8; int indx = recursive_binary_search(arr,num,0,len-1); printf("Index of %d is %d",num,indx); return 0; }
Index of 0 is 0
Index of 0 is 1
Index of 0 is 2
Index of 0 is 3
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