Back to Browse

GATE 2014 ALGORITHMS | ProcessArray(listA,x,n) Implementation of binary search, if (x=listA[k])j=k-1

258 views
Jan 30, 2022
14:36

GATE | GATE-CS-2014-(Set-3) | Question 65 Consider the C function given below. Assume that the array listA contains n ( 0) elements, sorted in ascending order. int ProcessArray(int *listA, int x, int n) { int i, j, k; i = 0;j = n-1; do {k = (i+j)/2; if (x = listA[k]) j = k-1; if (listA[k] = x) i = k+1;} while (i = j); if (listA[k] == x) return(k); else return -1;} Which one of the following statements about the function ProcessArray is CORRECT? A) It will run into an infinite loop when x is not in listA. (B) It is an implementation of binary search. (C) It will always find the maximum element in listA. (D) It will return −1 even when x is present in listA .For any queries feel free to comment or direct message on Instagram Instagram - https://www.instagram.com/jatingupta5jan/ Playlist link - C programming - https://www.youtube.com/playlist?list=PLnEHtQ3-a5paHibY82nRWmWOEfYYVXFZ4 Time Complexity - https://www.youtube.com/playlist?list=PLnEHtQ3-a5pY3k4u754YJ_NWMe_6ITHHX Data structure - https://www.youtube.com/playlist?list=PLnEHtQ3-a5pawoiSjUXy25JLpI0k4zQ2l Algorithms - https://www.youtube.com/playlist?list=PLnEHtQ3-a5pYgXnLQ5qN_xKA_vSGQbGr9 Binary tree - https://youtube.com/playlist?list=PLnEHtQ3-a5pYbHh6LzdBGKAKPJCLl_t5z Linked List - https://youtube.com/playlist?list=PLnEHtQ3-a5pYM_kmRl5bwk4CevYJtqQba #Jatin_Gupta_Gate

Download

0 formats

No download links available.

GATE 2014 ALGORITHMS | ProcessArray(listA,x,n) Implementation of binary search, if (x=listA[k])j=k-1 | NatokHD