Which of the following searching algorithm is fastest?
A. binary search
B. linear search
C. jump search
D. all are equally fast
Select an option to see the answer and solution.
Interpolation search performs better than binary search when?
A. array has uniformly distributed values but is not sorted
B. array is sorted and has uniform distribution of values
C. array is sorted but the values are not uniformly distributed
D. array is not sorted
Select an option to see the answer and solution.
What is the formula used for calculating the position in interpolation search?
(x = element being searched, A[] = input array, low and high are the leftmost and rightmost index of A[] respectively)
A. ((x - A[low]) * (high - low)) / (A[high] - A[low])
B. high + ((x - A[low]) * (high - low)) / (A[high] - A[low])
C. low + ((x - A[low]) * (high - low)) / (A[high] - A[low])
D. x + ((x - A[low]) * (high - low)) / (A[high] - A[low])
Select an option to see the answer and solution.
Jumps are made in the jump search algorithm until . . . . . . . .
A. element having value less than that of the required element is found
B. element having value equal to the median of values of the array is found
C. element having value greater than that of the required element is found
D. middle element is found equal to the element being searched
Select an option to see the answer and solution.
What is the best case for linear search?
A. O(nlogn)
B. O(logn)
C. O(n)
D. O(1)
Select an option to see the answer and solution.
What will be the auxiliary space complexity of the following code?
#include<bits/stdc++.h>
using namespace std;
void func(char* str2, char* str1)
{
int m = strlen(str2);
int n = strlen(str1);
for (int i = 0; i <= n - m; i++)
{
int j;
for (j = 0; j < m; j++)
if (str1[i + j] != str2[j])
break;
if (j == m)
cout << i << endl;
}
}
int main()
{
char str1[] = "1253234";
char str2[] = "323";
func(str2, str1);
return 0;
}A. O(n)
B. O(1)
C. O(log n)
D. O(m)
Select an option to see the answer and solution.
Linear search(recursive) algorithm used in . . . . . . . .
A. When the size of the dataset is low
B. When the size of the dataset is large
C. When the dataset is unordered
D. Never used
Select an option to see the answer and solution.
In which of the following case jump search performs better than interpolation search?
A. When array has uniformly distributed values but is not sorted
B. when array is sorted and has uniform distribution of values
C. when array is sorted but the values increases exponentially
D. when array is not sorted
Select an option to see the answer and solution.
Best case of jump search will have time complexity of . . . . . . . .
A. O(1)
B. O(n)
C. O(log n)
D. O(n log n)
Select an option to see the answer and solution.
What are the updated values of high and low in the array if the element being searched is greater than the value at calculated index in interpolation search? (pos = current position)
A. low = pos + 1, high remains unchanged
B. high = pos - 1, low remains unchanged
C. low = low +1, high = high - 1
D. low = pos +1, high = pos - 1
Select an option to see the answer and solution.
What is the time complexity of interpolation search when the input array has uniformly distributed values and is sorted?
A. O(n)
B. O(log log n)
C. O(n log n)
D. O(log n)
Select an option to see the answer and solution.
What is the time complexity of exponential sort?
A. O(n)
B. O(2n)
C. O(n log n)
D. O(log n)
Select an option to see the answer and solution.
What is the recurrence relation for the linear search recursive algorithm?
A. T(n-2)+c
B. 2T(n-1)+c
C. T(n-1)+c
D. T(n+1)+c
Select an option to see the answer and solution.
Which algorithmic technique does Fibonacci search use?
A. Brute force
B. Divide and Conquer
C. Greedy Technique
D. Backtracking
Select an option to see the answer and solution.
Interpolation search is a variation of?
A. Exponential search
B. Linear search
C. Binary search
D. Jump search
Select an option to see the answer and solution.
Jump search algorithm requires which of the following condition to be true?
A. array should be sorted
B. array should have not be sorted
C. array should have a less than 64 elements
D. array should be partially sorted
Select an option to see the answer and solution.
Jump search has a worst case time complexity of O(n).
Select an option to see the answer and solution.
Choose the incorrect statement about exponential search from the following.
A. Exponential search is an in place algorithm
B. Exponential search has a greater time complexity than binary search
C. Exponential search performs better than binary search when the element being searched is present near the starting point of the array
D. Jump search has a greater time complexity than an exponential search
Select an option to see the answer and solution.
Where is linear searching used?
A. Used all the time
B. When the list has only a few elements
C. When performing a single search in an unordered list
D. When the list has only a few elements and When performing a single search in an unordered list
Select an option to see the answer and solution.
Exponential search algorithm requires which of the following condition to be true?
A. array should be sorted
B. array should have not be sorted
C. array should have a less than 128 elements
D. array should be partially sorted
Select an option to see the answer and solution.