1 / 8

Searching for Information Using a Computer

Learn about different search methods used by computers, such as linear search, binary search, and hashing, for finding specific information quickly and efficiently.

buckman
Download Presentation

Searching for Information Using a Computer

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Searching for Information Using a Computer Module 3- Searching and Sorting

  2. Mobile Phones can query the amount of credit remaining. Bank tellers need to look up the balance for a customer’s account number On-line music stores are able to find the songs sung by a given artist. Why do Computers Need to Perform Searches? Some Examples

  3. Get a Search Key • For Example • Phone Number • Bank Account number • Song Artist/ Song title • Locate Information Related to the Search Key • For Example • Amount of Credit Remaining • Account Balance • Songs available for download • sung by that Artist How do Computers Perform Searches? The Method

  4. Game 1 The linear Search Go straight through a list Game 2 Binary Search Divide and Conquer Game 3 Keys in a hash tables are associated with values Types of Searches? Some Examples

  5. Linear Search • Computers work very quickly. • How efficient is a linear search? • E.g. Imagine starting at the first page of the phone book and checking every page until you find a phone number for a man called John Williams.

  6. Binary Search • Your items must be sorted in order for a binary search to work. • It is similar to how people locate information in a dictionary. • In the phone book example, a book with 1 million names can now be searched with a maximum of 20 probes, which might take two hundredths of a second—hardly noticeable.

  7. Binary Search

  8. Game 3 - Hashing • Data is stored at a specific location based on a hash function. Our game used a hash function to identify a column number for a ship. This column number (Hash Key) was created using the final digit of the sum of the digits of a ship’s number. • As you have seen, it was slow to find the right ship in a chosen column if there was a large number of ships in a column. However, it was very quick if there was just one ship in a column. • Hashing can be used for searching through lists of unsorted information. For example the Hong Kong Book. = 7 = 14

More Related