LBSorting - LOWER BOUND THEORY Searching ordered lists with...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
LOWER BOUND THEORY Searching ordered lists with Comparison–Based Algorithms Comparison-Based 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.
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 07/14/2011 for the course COT 4610 taught by Professor Dutton during the Fall '10 term at University of Central Florida.

Page1 / 3

LBSorting - LOWER BOUND THEORY Searching ordered lists with...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online