12.07.2015 Views

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

A Practical Introduction to Data Structures and Algorithm Analysis

SHOW MORE
SHOW LESS
  • No tags were found...

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 information is at the heart of most computer applications,<strong>and</strong> searching is surely the most frequently performed of all computing tasks.Search can be viewed abstractly as a process <strong>to</strong> determine if an element with a particularvalue is a member of a particular set. The more common view of searchingis an attempt <strong>to</strong> find the record within a collection of records that 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 k 1 , k 2 , ... k n are distinctkeys, <strong>and</strong> that we have a collection L of n records of the form(k 1 , I 1 ), (k 2 , I 2 ), ..., (k n , I n )where I j is information associated with key k j for 1 ≤ j ≤ n. Given a particularkey value K, the search problem is <strong>to</strong> locate the record (k j , I j ) in L such thatk j = K (if one exists). Searching is a systematic method for locating the record(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-match query is a search for the record whose key value matches aspecified key value. A range query is a search for all records whose key value fallswithin a specified range of key values.We can categorize search algorithms in<strong>to</strong> three general approaches:1. Sequential <strong>and</strong> list methods.2. Direct access by key value (hashing).3. Tree indexing methods.317

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

Saved successfully!

Ooh no, something went wrong!