Recall & Review
beginner
What is the main difference between linear search and binary search in terms of data requirements?
Linear search works on any list, sorted or unsorted. Binary search requires the list to be sorted before searching.
Click to reveal answer
beginner
How does the time complexity of linear search compare to binary search?
Linear search has a time complexity of O(n), meaning it may check every item. Binary search has a time complexity of O(log n), meaning it divides the search space in half each step.
Click to reveal answer
intermediate
Why might binary search not always be faster in real life despite its better time complexity?
Binary search requires the list to be sorted, which can take extra time if the list is unsorted. Also, for very small lists, the overhead of binary search steps might be slower than a simple linear search.
Click to reveal answer
intermediate
What is the real cost difference when searching in a very small list (e.g., 5 elements)?
For very small lists, linear search is often faster because it checks elements directly without extra calculations. Binary search's divide-and-conquer steps add overhead that may not pay off for small sizes.
Click to reveal answer
advanced
What is the impact of sorting on the total cost when using binary search on an unsorted list?
Sorting an unsorted list before binary search adds extra cost, usually O(n log n), which can outweigh the benefits of binary search if only one search is done.
Click to reveal answer
Which search algorithm can be used on an unsorted list without any preparation?
✗ Incorrect
Linear search checks each element one by one and does not require the list to be sorted.
What is the time complexity of binary search on a sorted list?
✗ Incorrect
Binary search divides the search space in half each step, resulting in O(log n) time complexity.
Why might linear search be faster than binary search on very small lists?
✗ Incorrect
Binary search involves calculations to find midpoints, which adds overhead that may not be worth it for small lists.
What extra step is needed before using binary search on an unsorted list?
✗ Incorrect
Binary search requires the list to be sorted to work correctly.
If you only need to search once in an unsorted list, which approach is usually better?
✗ Incorrect
Sorting takes extra time, so for a single search, linear search is often faster.
Explain the real cost difference between linear search and binary search when searching in small and large lists.
Think about preparation time and search steps.
You got /5 concepts.
Describe why binary search might not always be the best choice despite its better theoretical time complexity.
Consider practical factors beyond big O notation.
You got /4 concepts.