Given an input arr = {2, 5, 7, 99, 899}; key = 899; What is the level of recursion?
Select an option to see the answer and solution.
Exponential search performs better than binary search when the element being searched is present near the starting point of the array.
Select an option to see the answer and solution.
What is the best case runtime of linear search(recursive) algorithm on an ordered set of elements?
A. O(1)
B. O(n)
C. O(logn)
D. O(nx)
Select an option to see the answer and solution.
What does the following piece of code do?
for (int i = 0; i < arr.length-1; i++)
{
for (int j = i+1; j < arr.length; j++)
{
if( (arr[i].equals(arr[j])) && (i != j) )
{
System.out.println(arr[i]);
}
}
}A. Print the duplicate elements in the array
B. Print the element with maximum frequency
C. Print the unique elements in the array
D. Prints the element with minimum frequnecy
Select an option to see the answer and solution.
In which of the cases uniform binary search fails compared to binary search?
A. Complexity of code
B. Many searches will be performed on several arrays of the same length
C. Many searches will be performed on the same array
D. A table lookup is generally faster than an addition and a shift
Select an option to see the answer and solution.
What is the time complexity of uniform binary search?
A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2 )
Select an option to see the answer and solution.
What is the worst case complexity of binary search using recursion?
A. O(nlogn)
B. O(logn)
C. O(n)
D. O(n2 )
Select an option to see the answer and solution.
Which of the following searching algorithm is fastest when the input array is sorted and has uniformly distributed values?
A. jump search
B. exponential search
C. binary search
D. interpolation search
Select an option to see the answer and solution.
Best case of the exponential 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.
Exponential search has . . . . . . . .
A. neither an exponential space complexity nor exponential time complexity
B. exponential time complexity but a linear space complexity
C. exponential space complexity but a linear time complexity
D. both exponential time and space complexity
Select an option to see the answer and solution.
Which of the following is a disadvantage of linear search?
A. Requires more space
B. Greater time complexities compared to other searching algorithms
C. Not easy to understand
D. Not easy to implement
Select an option to see the answer and solution.
What is the advantage of recursive approach than an iterative approach?
A. Consumes less memory
B. Less code and easy to implement
C. Consumes more memory
D. More code has to be written
Select an option to see the answer and solution.
Which of the following is the most desirable condition for interpolation search?
A. array should be sorted
B. array should not be sorted but the values should be uniformly distributed
C. array should have a less than 64 elements
D. array should be sorted and the values should be uniformly distributed
Select an option to see the answer and solution.
Given delta[4] is a global array and number of elements in the sorted array is 10, what are the values in the delta array?
A. 4, 3, 1, 0
B. 5, 3, 1, 0
C. 4, 2, 1, 1
D. 5, 2, 1, 1
Select an option to see the answer and solution.
Which of the following false about Jump Search?
A. Jump Search is better than Linear Search
B. Useful when jumping back is more costly than jumping forward
C. Jump Search is worse than Binary Search
D. Jump search starts from the index 0 even though specified index is k
Select an option to see the answer and solution.
Which of the following is not an application of binary search?
A. To search in unordered list
B. Debugging
C. Union of intervals
D. To find the lower/upper bound in an ordered sequence
Select an option to see the answer and solution.
In which of the following case jump search will be preferred over binary search?
A. jumping backwards takes significantly more time than jumping forward
B. jumping forward takes significantly more time than jumping backwards
C. when the given array is very large in size
D. when the given array is very small in size
Select an option to see the answer and solution.
The array is as follows: 1, 2, 3, 6, 8, 10. Given that the number 17 is to be searched. At which call it tells that there's no such element? (By using linear search(recursive) algorithm)
A. 7th call
B. 9th call
C. 17th call
D. The function calls itself infinite number of times
Select an option to see the answer and solution.
What will be the worst case time 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(m)
C. O(m * n)
D. O(m + n)
Select an option to see the answer and solution.
What will be the best case time 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(m)
C. O(m * n)
D. O(m + n)
Select an option to see the answer and solution.