11.07.2015 Views

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

Data Structures and Algorithm Analysis - Computer Science at ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

9SearchingOrganizing <strong>and</strong> retrieving inform<strong>at</strong>ion is <strong>at</strong> the heart of most computer applic<strong>at</strong>ions,<strong>and</strong> searching is surely the most frequently performed of all computing tasks.Search can be viewed abstractly as a process to determine if an element with a particularvalue is a member of a particular set. The more common view of searchingis an <strong>at</strong>tempt to find the record within a collection of records th<strong>at</strong> has a particularkey value, or those records in a collection whose key values meet some criterionsuch as falling within a range of values.We can define searching formally as follows. Suppose th<strong>at</strong> we have a collectionL of n records of the form(k 1 , I 1 ), (k 2 , I 2 ), ..., (k n , I n )where I j is inform<strong>at</strong>ion associ<strong>at</strong>ed with key k j from record j for 1 ≤ j ≤ n. Givena particular key value K, the search problem is to loc<strong>at</strong>e a record (k j , I j ) in Lsuch th<strong>at</strong> k j = K (if one exists). Searching is a system<strong>at</strong>ic method for loc<strong>at</strong>ing therecord (or records) with key value k j = K.A successful search is one in which a record with key k j = K is found. Anunsuccessful search is one in which no record with k j = K is found (<strong>and</strong> no suchrecord exists).An exact-m<strong>at</strong>ch query is a search for the record whose key value m<strong>at</strong>ches aspecified key value. A range query is a search for all records whose key value fallswithin a specified range of key values.We can c<strong>at</strong>egorize search algorithms into three general approaches:1. Sequential <strong>and</strong> list methods.2. Direct access by key value (hashing).3. Tree indexing methods.This <strong>and</strong> the following chapter tre<strong>at</strong> these three approaches in turn. Any ofthese approaches are potentially suitable for implementing the Dictionary ADT301

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!