Core Concept Mastery • DSA Module
Do not use binary search on unsorted data. The result can be wrong or 'not found' even when the value is there. Summary: Linear = any order, O(n). Binary = sorted only, O(log n). Linked list = linear only.
Main pitfall
Using binary search on an unsorted list. The algorithm assumes order. If the list is not sorted, it can say "not found" when the value is there, or give a wrong answer. Always use linear search on unsorted data, or sort first and then use binary.
Cheat sheet