Professional Documents
Culture Documents
Computer Science Notes (College)
Computer Science Notes (College)
3. Question: What is the difference between a linear search and a binary search?
Answer:
- Linear Search: Checks each element of the list sequentially until the desired element is
found or the list ends. It has a time complexity of O(n).
- Binary Search: Efficiently finds an element by repeatedly dividing the sorted list in half and
comparing the target value to the middle element. It has a time complexity of O(log n).