Learn C++ in step-by-step lessons.
Searching an Array
Searching generally means finding one particular item in a list. If you are looking for everyone who worked overtime, or all items that need to be reordered, this is referred to as an exception report, not a search.
An exception report is straight forward: loop through every item: if it matches the criteria, print it out.
Goals:
- Understand different way of searching an array
Objectives:
- Exlain a sequential search
- Exlain a binary search
- Understand when to use a sequential or binary search
Please study the material at each of the links below.
We use a spreadsheet to demonstrate searching.- Sequential search
- The sequential search code
- A Binary Search
- A number guessing game
Glossary for search lesson
Full Glossary