One important problem in computing is that of locating information. More succinctly, this is problem is known as searching. The information to be searched has to be represented (or encoded) somehow. This is were data structures come in. As you have already seen, in a computer, everything is ultimately represented as a sequence of binary digits (bits). But this is too low level for our purposes. What we wish is to develop and study powerful data structures which are closer to the way we think (or at least more structured than mere sequences of bits). After all, it is us, humans, who have to develop software systems -- computers merely run them.
After we have chosen a suitable representation, the information has to be processed. In this case, the process is that of searching. This is where algorithms come in. To begin with, let's consider
It will be convenient to be able to write down arrays on paper. We just write its items in order, separated by commas and enclosed by square brackets. Thus,
If we ask where
is in the array
, the answer is
. If we ask
where
is, the answer is nowhere. Because we are not using
as a possible index (as we start counting from 0), we may, as
we do, use the number
to represent nowhere. Other (perhaps
better) conventions are possible, but we'll stick to this here.