

MCQOPTIONS
Saved Bookmarks
This section includes 40 Mcqs, each offering curated multiple-choice questions to sharpen your Data Structures and Algorithms knowledge and support exam preparation. Choose a topic below to get started.
1. |
Binary Search can be categorized into which of the following? |
A. | Brute Force technique |
B. | Divide and conquer |
C. | Greedy algorithm |
D. | Dynamic programming |
Answer» C. Greedy algorithm | |
2. |
What is the auxiliary space requirement of the jump search? |
A. | O(n) |
B. | O(log n) |
C. | O(n1/2) |
D. | O(1) |
Answer» E. | |
3. |
What is the value of jump taken for maximum efficiency while implementing jump search? |
A. | n/2 |
B. | n2 |
C. | n1/2 |
D. | log n |
Answer» D. log n | |
4. |
Which of the following searching algorithm is fastest? |
A. | jump search |
B. | binary search |
C. | linear search |
D. | all are equally fast |
Answer» C. linear search | |
5. |
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 |
Answer» B. jumping forward takes significantly more time than jumping backwards | |
6. |
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 |
Answer» B. array should have not be sorted | |
7. |
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 |
Answer» D. middle element is found equal to the element being searched | |
8. |
How many jumps will be made in the worst case of jump search(let block jumped =k)? |
A. | n*k |
B. | n/k |
C. | k/n |
D. | n+k |
Answer» C. k/n | |
9. |
What is the time complexity of uniform binary search? |
A. | O(nlogn) |
B. | O(logn) |
C. | O(n) |
D. | O(n2) |
Answer» C. O(n) | |
10. |
What are the applications of binary search? |
A. | To find the lower/upper bound in an ordered sequence |
B. | Union of intervals |
C. | Debugging |
D. | All of the mentioned |
Answer» E. | |
11. |
What is the time complexity of binary search with iteration? |
A. | O(nlogn) |
B. | O(logn) |
C. | O(n) |
D. | O(n2) |
Answer» C. O(n) | |
12. |
How can Jump Search be improved? |
A. | Start searching from the end |
B. | Begin from the kth item, where k is the step size |
C. | Cannot be improved |
D. | Step size should be other than sqrt(n) |
Answer» C. Cannot be improved | |
13. |
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) |
Answer» B. O(n) | |
14. |
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 |
Answer» D. T(n+1)+c | |
15. |
Is there any difference in the speed of execution between linear serach(recursive) vs linear search(lterative)? |
A. | Both execute at same speed |
B. | Linear search(recursive) is faster |
C. | Linear search(Iterative) is faster |
D. | Cant be said |
Answer» D. Cant be said | |
16. |
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 |
Answer» B. When the size of the dataset is large | |
17. |
Is the space consumed by the linear search(recursive) and linear search(iterative) same? |
A. | No, recursive algorithm consumes more space |
B. | No, recursive algorithm consumes less space |
C. | Yes |
D. | Nothing can be said |
Answer» B. No, recursive algorithm consumes less space | |
18. |
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. | All of the mentioned |
Answer» C. Not easy to understand | |
19. |
What is the best case and worst case complexity of ordered linear search? |
A. | O(nlogn), O(logn) |
B. | O(logn), O(nlogn) |
C. | O(n), O(1) |
D. | O(1), O(n) |
Answer» E. | |
20. |
Select the code snippet which performs unordered linear search iteratively? |
A. | int unorderedLinearSearch(int arr[], int size, int data){ int index; for(int i |
B. | int unorderedLinearSearch(int arr[], int size, int data){ int index; for(int i |
C. | int unorderedLinearSearch(int arr[], int size, int data){ int index; for(int i |
D. | None of the mentioned |
Answer» B. int unorderedLinearSearch(int arr[], int size, int data){ int index; for(int i | |
21. |
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 |
Answer» B. 9th call | |
22. |
Select the code snippet which performs ordered linear search iteratively? |
A. | public int linearSearch(int arr[],int key,int size) { int index = -1; < |
B. | public int linearSearch(int arr[],int key,int size) { int index = -1; < |
C. | public int linearSearch(int arr[],int key,int size) { int index = -1; < |
D. | None of the mentioned |
Answer» C. public int linearSearch(int arr[],int key,int size) { int index = -1; < | |
23. |
Given an array arr = {45,77,89,90,94,99,100} and key = 100; What are the mid values(corresponding array elements) generated in the first and second iterations? |
A. | 90 and 99 |
B. | 90 and 100 |
C. | 89 and 94 |
D. | 94 and 99 |
Answer» B. 90 and 100 | |
24. |
Choose the code snippet which uses recursion for linear search. |
A. | public void linSearch(int[] arr, int first, int last, int key){ if(first == last |
B. | public void linSearch(int[] arr, int first, int last, int key) { if(first == last |
C. | public void linSearch(int[] arr, int first, int last, int key){ if(first == last |
Answer» B. public void linSearch(int[] arr, int first, int last, int key) { if(first == last | |
25. |
Given, arr = {1,3,5,6,7,9,14,15,17,19} key = 17 and delta = {5,3,1,0}How many key comparisons are made?(exclude the comparison used to decide the left or right sub array) |
A. | 4 |
B. | 3 |
C. | 5 |
D. | 6 |
Answer» C. 5 | |
26. |
Select the code snippet which prints the element with maximum frequency. |
A. | public int findPopular(int[] a) { if (a == null || a.length == |
B. | public int findPopular(int[] a) { if (a == null || a.length == |
C. | public int findPopular(int[] a) { if (a == null || a.length == |
D. | None of the mentioned |
Answer» B. public int findPopular(int[] a) { if (a == null || a.length == | |
27. |
Given an array arr = {5,6,77,88,99} and key = 88; How many iterations are done until the element is found? |
A. | 1 |
B. | 3 |
C. | 4 |
D. | 2 |
Answer» E. | |
28. |
The array is as follows: 1,2,3,6,8,10. At what time the element 6 is found? (By using linear search(recursive) algorithm) |
A. | 4th call |
B. | 3rd call |
C. | 6th call |
D. | 5th call |
Answer» B. 3rd call | |
29. |
What is the average case time complexity of binary search using recursion? |
A. | O(nlogn) |
B. | O(logn) |
C. | O(n) |
D. | O(n2) |
Answer» C. O(n) | |
30. |
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. | None of the mentioned |
Answer» E. | |
31. |
Which of the following step is taken after finding an element having value greater than the element being searched? |
A. | linear search takes place in the forward direction |
B. | linear search takes place in the backward direction |
C. | binary search takes place in the forward direction |
D. | binary search takes place in a backward direction |
Answer» C. binary search takes place in the forward direction | |
32. |
Can linear search recursive algorithm and binary search recursive algorithm be performed on an unordered list? |
A. | Binary search can't be used |
B. | Linear search can't be used |
C. | Both cannot be used |
D. | Both can be used |
Answer» B. Linear search can't be used | |
33. |
What will be the maximum number of comparisons that can be made in jump search algorithm (assuming k to be blocks jumped)? |
A. | k |
B. | n/k |
C. | k-1 |
D. | k-1 |
Answer» D. k-1 | |
34. |
What is the worst case runtime of linear search(recursive) algorithm? |
A. | O(n) |
B. | O(logn) |
C. | O(n2) |
D. | O(nx) |
Answer» B. O(logn) | |
35. |
What is the time complexity of Jump Search? |
A. | O(logn) |
B. | O(n) |
C. | O(sqrt(n)) |
D. | O(nlogn) |
Answer» D. O(nlogn) | |
36. |
What is the length of the step in jump search? |
A. | n |
B. | n/2 |
C. | sqrt(n) |
D. | 1 |
Answer» D. 1 | |
37. |
Jump search has a worst case time complexity of O(n). |
A. | True |
B. | False |
Answer» C. | |
38. |
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) |
Answer» B. O(n) | |
39. |
Select the code snippet for Jump Search. |
A. | public int jumpSearch(int arr[], int key){ int size = arr.length; int step = flo |
B. | public int jumpSearch(int arr[], int key){ int size = arr.length; int step = flo |
C. | public int jumpSearch(int arr[], int key){ int size = arr.length; int step = flo |
D. | None of the mentioned |
Answer» C. public int jumpSearch(int arr[], int key){ int size = arr.length; int step = flo | |
40. |
Jump search is worse than linear search in terms of time complexity. |
A. | True |
B. | False |
Answer» C. | |