Data searches are fundamental techniques used to locate specific information within a dataset. This topic covers two core search algorithms — Linear Search and Binary Search — as well as approaches for collecting original data.
Linear Search is the simplest search algorithm. It examines each element in a list one by one, from the first element to the last, until the target value is found or the entire list has been checked.
| Feature | Detail |
|---|---|
| Works on | Sorted or unsorted data |
| Best case | — target is the first element |
| Worst case | — target is last or not present |
| Use case | Small lists or unsorted data |
Searching for 7 in the list [3, 9, 1, 7, 5]:
Binary Search is a much faster algorithm, but it requires the dataset to be sorted first. It works by repeatedly halving the search space.
| Feature | Detail |
|---|---|
| Prerequisite | Data must be sorted |
| Best case | — target is the middle element |
| Worst case | — halving continues until found |
| Use case | Large sorted datasets |
Searching for 7 in the sorted list [1, 3, 5, 7, 9]:
[7, 9]For a list of elements, the maximum number of comparisons in Binary Search is:
For example, for : comparisons maximum.
| Feature | Linear Search | Binary Search |
|---|---|---|
| Data requirement | Any (sorted or unsorted) | Must be sorted |
| Time complexity (worst) | ||
| Efficiency on large data | Poor | Excellent |
| Implementation complexity | Simple | Moderate |
Beyond algorithmic searches, researchers often need to gather original (primary) data when existing data is insufficient. This requires designing a data-collection approach.
| Goal | Recommended Method |
|---|---|
| Understand opinions/feelings | Qualitative interviews |
| Collect data from many people | Surveys |
| Test a design concept | Prototype |
| Model a complex system | Simulation |