Question 23
How many comparisons are required in the worst case a traditional linear search utilizes?
Question 24
In the worst case, (for instance where the numerical values of the keys increase exponentially) the interpolation search technique will take how many comparisons.?
Question 25
Match the following:
List - I | List - II |
(a) Fibonacci Search | (i) O(N) |
(b) Jump Search | (ii) O(√N) |
(c) Sentinel Linear Search | (iii) O(log2(log2 n)) |
(d) Interpolation Search | (iv) F(n) = F(n-1) + F(n-2) |
Hints:
(a) | (b) | (c) | (d) | |
(1) | (i) | (iv) | (iii) | (ii) |
(2) | (iv) | (i) | (ii) | (iii) |
(3) | (i) | (iv) | (ii) | (iii) |
(4) | (iv) | (ii) | (i) | (iii) |
Question 27
what is the output of the below code if the input array is [12, 34, 56, 29, 78]. and the X= 21?
int fun(int arr[], int N, int x)
{
for (int i = 0; i < N; i++)
if (arr[i] == x)
return i;
return -1;
}
Question 28
What is wrong with the below algorithm for searching the missing number from 1 to n?
int getMissingNo(int a[], int n) { int i, total; total = (n + 1) * (n + 2) / 2; for (i = 0; i < n; i++) total += a[i]; return total; }
There are 28 questions to complete.