InterviewSolution
Saved Bookmarks
| 1. |
How is linear search different from binary search? |
|
Answer» 1. Binary search requires the input data to be sorted near search doesn’t. 2. Binary search requires an ordering comparison; linear search only requires equality comparisons 3. Binary search has complexity 0(log n); linear search has complexity O(n) as discussed earlier. 4. Binary search requires random access to the data; linear search only requires sequential access (this can be very important – it means a linear search can stream data of arbitrary size). |
|