- 2075 Baisakh · 5 marks
Sequential vs binary search
Short answer
Sequential search works on sorted or unsorted data, worst O(n). Binary search requires a sorted array and direct access, worst O(log n), making it much faster for large lists.
Compare sequential search with binary search.
| Point | Sequential (linear) search | Binary search |
|---|---|---|
| Idea | Compare key with each element in order | Compare with middle element, discard half |
| Data order | Works on sorted or unsorted data | Data must be sorted |
| Time (worst) | O(n) | O(log n) |
| Time (best) | O(1) (first element) | O(1) (middle element) |
| Data structure | Array or linked list | Needs direct access, i.e. array |
| Code | Very simple | Slightly more complex |
| Best for | Small or unsorted lists | Large sorted lists |
| Average comparisons | about (n+1)/2 | about log₂ n |
Example: to find a key in 1,000 sorted items, sequential search may need up to 1,000 comparisons, binary search at most 10.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Sequential search and sentinel · Data Structure and Algorithm, chapter 8
- Binary search with algorithm and example · Data Structure and Algorithm, chapter 8 · asked 4×
- Binary search for 54 in sorted data · Data Structure and Algorithm, chapter 8
- Binary search for 89; hash functions · Data Structure and Algorithm, chapter 8
- Complexity of binary search · Data Structure and Algorithm, chapter 8
- Sentinel in sequential search · Data Structure and Algorithm, chapter 8
- Informed vs blind search; DFS vs BFS · Artificial Intelligence, chapter 3
- Combinational vs sequential; JK flip-flop · Basic Electronics Engineering, chapter 6
- Combinational vs sequential; BCD-to-decimal decoder · Digital Logic, chapter 4
- Combinational vs sequential; latch as bounce eliminator · Digital Logic, chapter 6