Computer Science · Ch 6 — Searching
Introduction
Introduction
We store things at home and later look for them when needed. Sometimes we remember exactly where an item is kept; other times we do not, and we have to search for it. A computer works in a similar way — it stores large amounts of data and must retrieve that data later when a user or a program asks for it.
Searching is the process of locating a particular element in a collection of elements. The result of a search tells us whether that element is present in the collection or not. If the element is present, we can also find out its position within the collection.
Searching is a fundamental technique in computer science. To design efficient algorithms, programmers must understand the different ways in which a collection of data can be searched for retrieval.
The textbook opens this chapter with a quote from computer scientist Brian Kernighan: “Even though most people won't be directly involved with programming, everyone is affected by computers, so an educated person should have a good understanding of how computer hardware, software, and networks operate.” This reminds us that understanding how computers work — including how they search through data — is valuable for everyone, not just programmers.