Introduction to Search Algorithms
Search algorithms are fundamental tools in computer science used to locate a specific item (the target) within a collection of data. In IB Computer Science, you are expected to understand, construct, and trace two core search algorithms:
- Linear Search , works on any list, sorted or unsorted
- Binary Search , works only on sorted lists, but is far more efficient for large datasets
Choosing the right search algorithm depends on the structure of your data and how frequently it changes.
Search Algorithm: A step-by-step procedure used to locate a specific element (the target) within a data structure such as an array or list.
Target: The specific value or item being searched for within a dataset.
Exam Tip
Always ask yourself two questions before choosing a search algorithm:
- Is the data sorted?
- How large is the dataset?
These two factors will guide you to the most appropriate choice.