next up previous contents
Next: Search keys Up: Binary search trees Previous: Binary search trees   Contents

The problem: Searching

As we have already seen, many applications involve finding a particular item in a collection of data. If the data is stored as an unsorted list or array, then to find the item in question, one obviously has to check each entry (until the correct one is found or the collection is exhausted). On average, if there are $ n$ items, this will take $ n/2$ attempts and in the worst case, all $ n$ items will have to be checked. If the collection is large, a lot of time will be spent doing this (think, for example, of the collection of items accessible via the World Wide Web).



Martin Escardo 2005-01-11