WorksheetsUnderstanding Search Algorithms
Total questions: 10
Worksheet time: 5mins
What is the time complexity of linear search in the worst case?
O(n)
O(log n)
O(n^2)
O(1)
Which of the following is a requirement for binary search to work?
The data must be sorted.
The data must be in pairs.
The data must be unique.
The data must be in ascending order.
What is the average time complexity of binary search?
O(1)
O(log n)
O(n)
O(n log n)
In which scenario is linear search preferred over binary search?
When the dataset is small.
When the data is sorted.
When the data is unsorted.
When searching for a specific value.
What is the main advantage of binary search over linear search?
Binary search requires unsorted data for optimal performance.
Binary search is faster due to its O(log n) time complexity.
Binary search is slower with O(n) time complexity.
Linear search is more efficient for large datasets.
How does the time complexity of linear search compare to that of binary search?
Linear search is O(1) while binary search is O(n).
Linear search is O(n^2) while binary search is O(n).
Linear search is O(log n) while binary search is O(n).
Linear search is O(n) while binary search is O(log n).
What type of data structure is required for binary search?
Sorted array or sorted list
Linked list or tree structure
Unsorted array or unsorted list
Hash table or set
Which algorithm is generally faster for large datasets, linear search or binary search?
Binary search
Sequential search
Exponential search
Jump search
What is the best-case time complexity of linear search?
O(n^2)
O(n)
O(1)
O(log n)
In a sorted array of 1000 elements, how many comparisons would binary search make in the worst case?
20
10
15
5
