LOWER BOUND THEORY
Searching ordered lists with Comparison–Based Algorithms
ComparisonBased Algorithms
: Information can be gained only by comparing key–to–
element, or element–to–element (in some problems).
Given:
An integer n, a key, and an ordered list of n values.
Question:
Is the key in the list and, if so, at what index?
We have an algorithm. We don't know what it is, or how it works. It accepts n, a key and
a list on n values. That's it.
It MUST, though, work pretty much as follows:
1) It must calculate an index for the first compare based solely upon n since it has not yet
compared the key against anything, i.e., it has not yet obtained any additional
information. Notice, this means for a fixed value of n, the position of the first compare
is fixed for all data sets (of size n).
2) The following is repeated until the key is found, or until it is determined that no
location contains the key:
The key is compared against the item at the specified index.
a) If they are equal, the algorithm halts.
b) If the key is less, then it incorporates this information and computes a new
index.
c) If the key is greater, then it incorporates this information and computes a new
index
There are no rules about how this must be done. In fact we want to leave it wide
open so that we are not eliminating any possible algorithm.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
This is the end of the preview.
Sign up
to
access the rest of the document.
 Fall '10
 Dutton
 Algorithms, Sort, Search algorithm, Comparison–Based Algorithms, comparison–based search algorithm

Click to edit the document details