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;
}Related Algorithms PYQs
Suppose we have a balanced binary search tree T holding n numbers. We are given two numbers L and H and wish to sum up all the num…
Which one of the following correctly determines the solution of the recurrence relation with T(1) = 1? T(n) = 2T(n / 2) + log n
Suppose you are provided with the following function declaration in the C programming language: ```c int partition(int a[ ], int n…
Which one of the following is the recurrence equation for the worst case time complexity of the Quicksort algorithm for sorting n …
You have an array of n elements. Suppose you implement quick sort by always choosing the central element of the array as the pivot…
Let P be a quick sort program to sort numbers in ascending order using the first element as the pivot. Let t1 and t2 be the number…
Free account benefits
Turn practice into measurable progress
Public PYQs and reference pages stay free. Sign in when you want GATEverse to remember what you studied and guide what to practise next.