Each question below shows the correct answer with a full explanation. Use these to build conceptual understanding before attempting a timed quiz.
Searching AlgorithmsEasy
Q1. What does binary search return if the element is not found?
- A.The middle index of the array
- B.The value zero always
- C.The last index of the array
- D.An indicator such as -1 for not found✓ Correct
Explanation
Binary search typically returns -1 or a similar sentinel value to indicate the element was not found.
Report an error in this question
Searching AlgorithmsEasy
Q2. What is the time complexity of binary search?
- A.O(log n)✓ Correct
- B.O(n^2)
- C.O(n)
- D.O(1)
Explanation
Binary search divides the search space in half at each step, giving O(log n) time complexity.
Report an error in this question
Searching AlgorithmsEasy
Q3. What is the best-case time complexity of linear search?
- A.O(1)✓ Correct
- B.O(n)
- C.O(log n)
- D.O(n^2)
Explanation
The best case for linear search is O(1), when the target element is at the first position.
Report an error in this question
Searching AlgorithmsEasy
Q4. Which search algorithm does not require the data to be sorted?
- A.Interpolation search
- B.Linear search✓ Correct
- C.Fibonacci search
- D.Binary search
Explanation
Linear search works on both sorted and unsorted data since it checks each element sequentially.
Report an error in this question
Searching AlgorithmsEasy
Q5. What is the time complexity of linear search in the worst case?
- A.O(n^2)
- B.O(log n)
- C.O(n)✓ Correct
- D.O(1)
Explanation
In the worst case, linear search must check every element, giving O(n) time complexity.
Report an error in this question
Searching AlgorithmsEasy
Q6. How many comparisons does binary search make for an array of 1024 elements in the worst case?
- A.100
- B.10✓ Correct
- C.1024
- D.512
Explanation
Binary search makes at most log2(1024) + 1 = 11 comparisons, approximately 10 divisions of the search space.
Report an error in this question
Searching AlgorithmsEasy
Q7. What is the prerequisite for binary search?
- A.The array must be sorted✓ Correct
- B.The array must be of fixed size
- C.The array must contain unique elements
- D.The array must be unsorted
Explanation
Binary search requires the array to be sorted in order to repeatedly divide the search space in half.
Report an error in this question
Searching AlgorithmsEasy
Q8. What is linear search?
- A.Searching using a hash table for lookups
- B.Searching only in a sorted array format
- C.Searching each element sequentially from start✓ Correct
- D.Searching by dividing the array in half
Explanation
Linear search checks each element of the list sequentially until the target element is found or the list ends.
Report an error in this question
Searching AlgorithmsEasy
Q9. In binary search, if the target is greater than the middle element, where do you search next?
- A.Start over again
- B.Middle element only
- C.Left half only
- D.Right half only✓ Correct
Explanation
If the target is greater than the middle element in a sorted array, it must be in the right half.
Report an error in this question
Searching AlgorithmsMedium
Q10. What is the average time complexity of interpolation search on uniformly distributed data?
- A.O(log n)
- B.O(1)
- C.O(n)
- D.O(log log n)✓ Correct
Explanation
For uniformly distributed sorted data, interpolation search achieves O(log log n) average time complexity.
Report an error in this question
Searching AlgorithmsMedium
Q11. What is the optimal block size for jump search on an array of n elements?
- A.log n
- B.√n✓ Correct
- C.n
- D.n/2
Explanation
The optimal block size for jump search is √n, which minimizes the total number of comparisons to O(√n).
Report an error in this question
Searching AlgorithmsMedium
Q12. What is jump search?
- A.A search that uses recursion to jump elements
- B.A search that jumps by blocks then does linear scan✓ Correct
- C.A search that jumps to random positions in array
- D.A search that skips every other element each pass
Explanation
Jump search divides a sorted array into blocks of size √n, jumps ahead block by block, then does a linear search within the identified block.
Report an error in this question
Searching AlgorithmsEasy
Q13. What is the space complexity of iterative binary search?
- A.O(log n)
- B.O(n)
- C.O(n^2)
- D.O(1)✓ Correct
Explanation
Iterative binary search uses a constant amount of extra space (a few variables), giving O(1) space complexity.
Report an error in this question
Searching AlgorithmsMedium
Q14. What is exponential search?
- A.A search with exponential time complexity overall
- B.A search designed for exponentially growing datasets
- C.A search that doubles the index then uses binary search✓ Correct
- D.A search that uses exponential mathematical functions
Explanation
Exponential search finds the range where the element may exist by doubling the index (1, 2, 4, 8, ...), then performs binary search within that range.
Report an error in this question
Searching AlgorithmsMedium
Q15. What is interpolation search?
- A.A recursive linear search with memoization cache
- B.A search that always checks the middle element
- C.A search that uses a hash table for fast lookups
- D.A search that estimates position based on value distribution✓ Correct
Explanation
Interpolation search estimates the position of the target using the formula based on the distribution of values, working best on uniformly distributed sorted data.
Report an error in this question
Searching AlgorithmsMedium
Q16. What is ternary search?
- A.A three-pass sequential linear search method
- B.A search specifically for the third element only
- C.A search dividing array into three parts each step✓ Correct
- D.A search that checks three elements at a time
Explanation
Ternary search divides the sorted array into three parts using two mid-points and eliminates one-third of the array at each step.
Report an error in this question
Searching AlgorithmsMedium
Q17. What is the space complexity of recursive binary search?
- A.O(n)
- B.O(n^2)
- C.O(log n)✓ Correct
- D.O(1)
Explanation
Recursive binary search uses O(log n) space due to the recursion stack, as it makes at most log n recursive calls.
Report an error in this question
Searching AlgorithmsMedium
Q18. Why is binary search preferred over ternary search in practice?
- A.Binary search uses less memory per recursive call
- B.Binary search is always faster in every case
- C.Ternary search does not work on sorted arrays at all
- D.Ternary search makes more comparisons per step overall✓ Correct
Explanation
Ternary search makes 2 comparisons per step vs 1 for binary search. Though it has fewer levels (log3 n vs log2 n), the total comparisons are higher.
Report an error in this question
Searching AlgorithmsMedium
Q19. What is the time complexity of exponential search?
- A.O(n)
- B.O(√n)
- C.O(n log n)
- D.O(log n)✓ Correct
Explanation
Exponential search runs in O(log n) time: O(log i) to find the range and O(log i) for binary search within it, where i is the index of the target.
Report an error in this question
Searching AlgorithmsMedium
Q20. In which scenario is linear search more efficient than binary search?
- A.When the array has millions of elements
- B.Linear search is never more efficient
- C.Large sorted arrays with many elements
- D.When the array is unsorted and small✓ Correct
Explanation
For small or unsorted arrays, linear search can be more efficient since binary search requires sorting first and has overhead from index calculations.
Report an error in this question
Searching AlgorithmsHard
Q21. What is the worst-case time complexity of interpolation search?
- A.O(n)✓ Correct
- B.O(log n)
- C.O(log log n)
- D.O(√n)
Explanation
In the worst case (e.g., exponentially distributed data), interpolation search degrades to O(n).
Report an error in this question
Searching AlgorithmsHard
Q22. What is the time complexity of the Quickselect algorithm in the average case?
- A.O(n log n)
- B.O(n^2)
- C.O(log n)
- D.O(n)✓ Correct
Explanation
Quickselect, based on the partition step of QuickSort, finds the k-th element in O(n) average time by only recursing on one side.
Report an error in this question
Searching AlgorithmsHard
Q23. How does binary search handle finding the first occurrence of a duplicate element in a sorted array?
- A.Standard binary search always finds the first occurrence automatically
- B.Binary search cannot handle duplicate elements in sorted arrays
- C.By using linear search after binary search locates any occurrence
- D.By modifying binary search to continue searching left after finding it✓ Correct
Explanation
To find the first occurrence, modify binary search so that when the target is found, continue searching in the left half to check for earlier occurrences.
Report an error in this question
Searching AlgorithmsHard
Q24. How can you search in a sorted and rotated array?
- A.Interpolation search handles rotation natively
- B.Only linear search works for this case
- C.Modified binary search identifies the sorted half✓ Correct
- D.Ternary search is the only viable approach
Explanation
A modified binary search can determine which half of the array is sorted and decide which half to search in, achieving O(log n) time.
Report an error in this question
Searching AlgorithmsHard
Q25. What is the time complexity of searching in a balanced binary search tree?
- A.O(n log n)
- B.O(n)
- C.O(log n)✓ Correct
- D.O(1)
Explanation
A balanced BST has height O(log n), so searching follows a path from root to leaf in O(log n) time.
Report an error in this question
Searching AlgorithmsHard
Q26. What is two-pointer technique in searching?
- A.Using two separate arrays for searching data
- B.Searching for two distinct elements at once
- C.Binary search implemented with two mid points
- D.Using two pointers from different positions to converge✓ Correct
Explanation
The two-pointer technique uses two pointers (often from opposite ends) that move toward each other based on conditions, commonly used for pair-sum problems in sorted arrays.
Report an error in this question
Searching AlgorithmsHard
Q27. What is the time complexity of searching in a skip list?
- A.O(log n) expected✓ Correct
- B.O(1) constant
- C.O(n) linear
- D.O(n log n) total
Explanation
A skip list provides O(log n) expected search time by maintaining multiple levels of linked lists with probabilistic balancing.
Report an error in this question
Searching AlgorithmsHard
Q28. What is the time complexity of finding the median of two sorted arrays of sizes m and n?
- A.O((m + n) log(m + n))
- B.O(m × n)
- C.O(m + n)
- D.O(log(min(m, n)))✓ Correct
Explanation
Using binary search on the smaller array, the median of two sorted arrays can be found in O(log(min(m, n))) time.
Report an error in this question
Searching AlgorithmsHard
Q29. What is Fibonacci search?
- A.A search on Fibonacci heap data structures
- B.A recursive search with Fibonacci-like recurrence
- C.Searching for Fibonacci numbers in an array
- D.A search using Fibonacci numbers to divide array✓ Correct
Explanation
Fibonacci search uses Fibonacci numbers to divide the sorted array into sections of unequal sizes, avoiding division operations unlike binary search.
Report an error in this question
Searching AlgorithmsHard
Q30. What is the order-statistic problem?
- A.Counting elements in a range
- B.Finding the median of sorted data
- C.Finding the k-th smallest element✓ Correct
- D.Sorting all elements into order
Explanation
The order-statistic problem involves finding the k-th smallest (or largest) element in an unsorted collection.
Report an error in this question