InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which of the following searching algorithm is fastest when the input array is sorted but has non uniformly distributed values?(a) jump search(b) linear search(c) binary search(d) interpolation searchA simple yet interesting question from data structure and algorithms. |
|
Answer» CORRECT option is (C) binary search Easy explanation - INTERPOLATION search has a time complexity of O(n) when the array does not have UNIFORMLY distributed values. So in such a CASE binary search has the least time complexity out of the given options. |
|
| 2. |
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 sortedThis is one of most asked question in data structure and algorithms interview. |
|
Answer» Right option is (B) ARRAY is sorted and has uniform distribution of values |
|
| 3. |
Rabin Karp algorithm and naive pattern searching algorithm have the same worst case time complexity.(a) true(b) falseI had been asked this question by my school principal while I was bunking the class.This is a very interesting question from Searching in portion Searching of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (a) true Best explanation: The WORST case time complexity of Rabin Karp ALGORITHM is O(m*N) but it has a linear average case time complexity. So Rabin Karp and naive pattern searching algorithm have the same worst case time complexity. |
|
| 4. |
The naive pattern searching algorithm is an in place algorithm.(a) true(b) falseThe question was posed to me in examination.My question is based upon Searching in section Searching of Data Structures & Algorithms II |
|
Answer» The CORRECT answer is (a) true |
|
| 5. |
What is the auxiliary space complexity of Z algorithm for pattern searching (m = length of text, n = length of pattern)?(a) O(n + m)(b) O(m)(c) O(n)(d) O(m * n)I got this question in an online quiz.I'm obligated to ask this question of Searching topic in division Searching of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (B) O(m) |
|
| 6. |
What is the time complexity of Z algorithm for pattern searching (m = length of text, n = length of pattern)?(a) O(n + m)(b) O(m)(c) O(n)(d) O(m * n)I had been asked this question in a job interview.My question is from Searching topic in portion Searching of Data Structures & Algorithms II |
|
Answer» Correct option is (a) O(N + m) |
|
| 7. |
What is the worst case time complexity of KMP algorithm for pattern searching (m = length of text, n = length of pattern)?(a) O(n)(b) O(n*m)(c) O(m)(d) O(log n)I had been asked this question during an online exam.This interesting question is from Searching topic in section Searching of Data Structures & Algorithms II |
|
Answer» Correct CHOICE is (c) O(m) |
|
| 8. |
Which of the following is a sub string of “SANFOUNDRY”?(a) SANO(b) FOUND(c) SAND(d) FONDThe question was posed to me in an online quiz.The doubt is from Searching topic in division Searching of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (b) FOUND |
|
| 9. |
What are the updated values of high and low in the array if the element being searched is lower 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 – 1I have been asked this question in an online interview.The above asked question is from Searching in chapter Searching of Data Structures & Algorithms II |
|
Answer» Correct choice is (b) high = pos – 1, LOW remains unchanged |
|
| 10. |
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 – 1I have been asked this question by my college director while I was bunking the class.This question is from Searching in portion Searching of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (a) low = pos + 1, HIGH REMAINS unchanged The best I can explain: When the ELEMENT being searched is greater than the VALUE at the calculated position then in that case we update low and high remains unaltered. Updated value of low is low = pos + 1. |
|
| 11. |
Interpolation search has a better time complexity than exponential search for any given array.(a) True(b) FalseI had been asked this question at a job interview.I'm obligated to ask this question of Searching in division Searching of Data Structures & Algorithms II |
|
Answer» The correct choice is (B) False |
|
| 12. |
Interpolation search is an in place algorithm.(a) true(b) falseThe question was asked in an internship interview.I need to ask this question from Searching in portion Searching of Data Structures & Algorithms II |
|
Answer» RIGHT CHOICE is (a) true The best EXPLANATION: INTERPOLATION search has an auxiliary space complexity of O(1). So it qualifies as an in place algorithm. |
|
| 13. |
Which of the following searching algorithm is fastest when the input array is not sorted but has uniformly distributed values?(a) jump search(b) linear search(c) binary search(d) interpolation searchThis question was posed to me by my college director while I was bunking the class.This intriguing question originated from Searching in chapter Searching of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (B) linear search |
|
| 14. |
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 searchThis question was addressed to me in an interview.Question is taken from Searching topic in division Searching of Data Structures & Algorithms II |
|
Answer» RIGHT choice is (d) interpolation search Easy explanation - Interpolation search has a time complexity of O( LOG log n) when the array is sorted and has uniformly distributed values. It has the LEAST time complexity out of the given options for such a CASE. |
|
| 15. |
What is the time complexity of exponential search when the input array is sorted but the values are not uniformly distributed?(a) O(n^1/2)(b) O(log log n)(c) O(n)(d) O(log n)The question was asked in semester exam.This key question is from Searching topic in portion Searching of Data Structures & Algorithms II |
|
Answer» The correct choice is (c) O(N) |
|
| 16. |
What is the auxiliary space requirement of interpolation search?(a) O(n)(b) O(2^n)(c) O(1)(d) O(log n)I had been asked this question during an online exam.This intriguing question originated from Searching topic in division Searching of Data Structures & Algorithms II |
|
Answer» Right CHOICE is (c) O(1) |
|
| 17. |
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)I had been asked this question in an international level competition.I'm obligated to ask this question of Searching topic in chapter Searching of Data Structures & Algorithms II |
|
Answer» The correct OPTION is (b) O(log log n) |
|
| 18. |
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 sortedI have been asked this question in homework.My question is based upon Searching in section Searching of Data Structures & Algorithms II |
|
Answer» Correct option is (c) when array is sorted but the values increases exponentially |
|
| 19. |
Interpolation search is a variation of?(a) Linear search(b) Binary search(c) Jump search(d) Exponential searchThis question was posed to me during an online interview.My doubt stems from Searching topic in division Searching of Data Structures & Algorithms II |
|
Answer» The correct option is (B) Binary search |
|
| 20. |
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 distributedThe question was asked in semester exam.My question comes from Searching in division Searching of Data Structures & Algorithms II |
|
Answer» Right answer is (d) ARRAY should be sorted and the VALUES should be uniformly distributed |
|
| 21. |
Which of the following is not an alternate name of exponential search?(a) Logarithmic search(b) Doubling search(c) Galloping search(d) Struzik searchThis question was posed to me in an interview for job.My doubt is from Searching topic in section Searching of Data Structures & Algorithms II |
|
Answer» Correct option is (a) Logarithmic search |
|
| 22. |
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 searchThe question was posed to me in an interview for job.Asked question is from Searching in portion Searching of Data Structures & Algorithms II |
|
Answer» Right option is (b) Exponential search has a greater TIME complexity than BINARY search |
|
| 23. |
Exponential search performs better than binary search when the element being searched is present near the starting point of the array.(a) True(b) FalseThe question was posed to me by my college director while I was bunking the class.This intriguing question comes from Searching topic in portion Searching of Data Structures & Algorithms II |
|
Answer» Correct answer is (a) True |
|
| 24. |
What is the auxiliary space requirement of the exponential sort when used with recursive binary search?(a) O(n)(b) O(2^n)(c) O(1)(d) O(log n)I have been asked this question during a job interview.My question is from Searching topic in chapter Searching of Data Structures & Algorithms II |
|
Answer» The correct answer is (d) O(log n) |
|
| 25. |
What is the auxiliary space requirement of an exponential sort when used with iterative binary search?(a) O(n)(b) O(2^n)(c) O(1)(d) O(log n)The question was asked in an online quiz.Enquiry is from Searching in portion Searching of Data Structures & Algorithms II |
|
Answer» Right CHOICE is (c) O(1) |
|
| 26. |
Jump search has a worst case time complexity of O(n).(a) True(b) FalseThe question was asked during an interview.My question is taken from Searching in division Searching of Data Structures & Algorithms II |
|
Answer» Right option is (b) False |
|
| 27. |
What is the auxiliary space requirement of the jump search?(a) O(n)(b) O(log n)(c) O(n^1/2)(d) O(1)I got this question during an interview.This interesting question is from Searching topic in division Searching of Data Structures & Algorithms II |
|
Answer» RIGHT OPTION is (d) O(1) Easy explanation - Jump SEARCH does not require any additional space for searching the required element. Thus its auxiliary space requirement will be O(1). |
|
| 28. |
What is the value of jump taken for maximum efficiency while implementing jump search?(a) n/2(b) n^2(c) n^1/2(d) log nI had been asked this question in a national level competition.I need to ask this question from Searching topic in chapter Searching of Data Structures & Algorithms II |
|
Answer» Correct choice is (C) n^1/2 |
|
| 29. |
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-1This question was addressed to me in class test.Question is from Searching in division Searching of Data Structures & Algorithms II |
|
Answer» Right choice is (c) k-1 |
|
| 30. |
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+kThis question was posed to me by my school principal while I was bunking the class.Question is taken from Searching in chapter Searching of Data Structures & Algorithms II |
|
Answer» The CORRECT ANSWER is (b) n/k |
|
| 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 directionThe question was asked in an interview.This key question is from Searching in section Searching of Data Structures & Algorithms II |
|
Answer» Right ANSWER is (b) linear SEARCH takes place in the BACKWARD DIRECTION |
|
| 32. |
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 searchedThe question was asked by my school teacher while I was bunking the class.I'd like to ask this question from Searching topic in section Searching of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (c) element having value greater than that of the REQUIRED element is found |
|
| 33. |
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 sortedI got this question in my homework.I'd like to ask this question from Searching topic in chapter Searching of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (a) array should be sorted |
|
| 34. |
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 kI got this question in unit test.This key question is from Uniform Binary Search in chapter Searching of Data Structures & Algorithms II |
|
Answer» Correct OPTION is (d) Jump search starts from the index 0 even though specified index is k |
|
| 35. |
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)This question was addressed to me in final exam.This intriguing question comes from Uniform Binary Search topic in portion Searching of Data Structures & Algorithms II |
|
Answer» Correct choice is (B) BEGIN from the kth item, where k is the step size |
|
| 36. |
What is the time complexity of binary search with iteration?(a) O(nlogn)(b) O(logn)(c) O(n)(d) O(n^2)This question was addressed to me in final exam.My query is from Binary Search Iterative topic in portion Searching of Data Structures & Algorithms II |
|
Answer» Correct choice is (B) O(LOGN) |
|
| 37. |
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 99The question was posed to me in an online interview.The above asked question is from Binary Search Iterative topic in portion Searching of Data Structures & Algorithms II |
|
Answer» Correct ANSWER is (a) 90 and 99 |
|
| 38. |
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) 2I had been asked this question during an interview.My question is taken from Binary Search Iterative in section Searching of Data Structures & Algorithms II |
|
Answer» RIGHT OPTION is (d) 2 For explanation: Iteration1 : mid = 77; Iteration2 : mid = 88; |
|
| 39. |
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)+cI got this question in semester exam.Query is from Searching in portion Searching of Data Structures & Algorithms II |
|
Answer» Right answer is (c) T(n-1)+c |
|
| 40. |
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 usedThe question was asked at a job interview.This intriguing question comes from Searching in section Searching of Data Structures & Algorithms II |
|
Answer» Correct CHOICE is (a) When the size of the dataset is low |
|
| 41. |
What is the worst case runtime of linear search(recursive) algorithm?(a) O(n)(b) O(logn)(c) O(n^2)(d) O(nx)I had been asked this question at a job interview.The question is from Searching in portion Searching of Data Structures & Algorithms II |
|
Answer» Correct choice is (a) O(N) |
|
| 42. |
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 saidI had been asked this question in an interview for job.The question is from Searching topic in section Searching of Data Structures & Algorithms II |
|
Answer» CORRECT answer is (a) No, recursive algorithm CONSUMES more space For explanation: The recursive algorithm consumes more space as it INVOLVES the USAGE the stack space(CALLS the function numerous times). |
|
| 43. |
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 saidThis question was posed to me during an interview.I need to ask this question from Searching in section Searching of Data Structures & Algorithms II |
|
Answer» The correct choice is (c) Linear SEARCH(Iterative) is FASTER |
|