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

Slides:



Advertisements
Similar presentations
Searching for Data Relationship between searching and sorting Simple linear searching Linear searching of sorted data Searching for string or numeric data.
Advertisements

CompSci Searching & Sorting. CompSci Searching & Sorting The Plan  Searching  Sorting  Java Context.
HST 952 Computing for Biomedical Scientists Lecture 9.
Data Structures Data Structures Topic #13. Today’s Agenda Sorting Algorithms: Recursive –mergesort –quicksort As we learn about each sorting algorithm,
1 Hashing (Walls & Mirrors - end of Chapter 12). 2 I hate quotations. Tell me what you know. – Ralph Waldo Emerson.
Efficiency of Algorithms February 19th. Today Binary search –Algorithm and analysis Order-of-magnitude analysis of algorithm efficiency –Review Sorting.
CS 104 Introduction to Computer Science and Graphics Problems Data Structure & Algorithms (3) Recurrence Relation 11/11 ~ 11/14/2008 Yang Song.
Table design screen Field name Data type Field size Other properties.
Sorting Algorithms and Analysis Robert Duncan. Refresher on Big-O  O(2^N)Exponential  O(N^2)Quadratic  O(N log N)Linear/Log  O(N)Linear  O(log N)Log.
Database Software Application
Database terms Mr. Brunton.
1. 2 Problem RT&T is a large phone company, and they want to provide enhanced caller ID capability: –given a phone number, return the caller’s name –phone.
Programming Concepts Jacques Tiberghien office : Mobile :
COMP 1001: Introduction to Computers for Arts and Social Sciences Searching Algorithms Monday, May 30, 2011.
1 Hash table. 2 Objective To learn: Hash function Linear probing Quadratic probing Chained hash table.
1 5. Abstract Data Structures & Algorithms 5.2 Static Data Structures.
1 HASHING Course teacher: Moona Kanwal. 2 Hashing Mathematical concept –To define any number as set of numbers in given interval –To cut down part of.
HASHING PROJECT 1. SEARCHING DATA STRUCTURES Consider a set of data with N data items stored in some data structure We must be able to insert, delete.
Lecture on Binary Search and Sorting. Another Algorithm Example SEARCHING: a common problem in computer science involves storing and maintaining large.
Sorting and Searching by Dr P.Padmanabham Professor (CSE)&Director
Hash Tables ADT Data Dictionary, with two operations – Insert an item, – Search for (and retrieve) an item How should we implement a data dictionary? –
Alighieri: Introduction to MS Access 1 What is a Database? RELATIONAL DATABASE A database is an organized collection of information. A database is designed.
CENTURY 21 ACCOUNTING © Thomson/South-Western LESSON 11-3 Posting from Journals to a General Ledger.
1 compares each element of the array with the search key. works well for small arrays or for unsorted arrays works for any table slow can put more commonly.
Searching and Sorting Copyright Prentice Hall (with additions / modifications by Evan Korth)
1 Microsoft Imagine Cup
Copyright Prentice Hall Modified by Sana odeh, NYU
CSC 421: Algorithm Design & Analysis
Searching and Sorting Algorithms
LESSON 5-2 Bank Reconciliation
Design & Analysis of Algorithm Hashing
Course Developer/Writer: A. J. Ikuomola
Introduction to Database Systems
Data Structures Using C++ 2E
Lecture No.43 Data Structures Dr. Sohail Aslam.
Searching an Array: Binary Search
Week 12 Option 3: Database Design
Sorting by Tammy Bailey
CSC 421: Algorithm Design & Analysis
Hash tables Hash table: a list of some fixed size, that positions elements according to an algorithm called a hash function … hash function h(element)
Hash Table.
Searching.
Data Structures and Organization (p.2 – Arrays)
Scratch Where Are You Now?
MSIS 655 Advanced Business Applications Programming
Discrete Mathematics CMP-101 Lecture 12 Sorting, Bubble Sort, Insertion Sort, Greedy Algorithms Abdul Hameed
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
Using a database.
Searching CLRS, Sections 9.1 – 9.3.
LESSON 5-2 Bank Reconciliation
One-Pass Algorithms for Database Operations (15.2)
A Hash Table with Chaining
CS 2210 Discrete Structures Advanced Counting
Hashing Sections 10.2 – 10.3 Lecture 26 CS302 Data Structures
LESSON 5-2 Bank Reconciliation
Hash Tables Chapter 12 discusses several ways of storing information in an array, and later searching for the information. Hash tables are a common.
CPS120: Introduction to Computer Science
LESSON 11-3 Posting from Journals to a General Ledger
What is America (to you)? How does art allow us to define America?
CPS120: Introduction to Computer Science
Binary Search Counting
LESSON 11-3 Posting from Journals to a General Ledger
LESSON 11-3 Posting from Journals to a General Ledger
The multiples of Delete this text and write about what you notice:
LESSON 5-2 Bank Reconciliation
CS203 Lecture 15.
Data Structures Using C++ 2E
STARTING A NEW PAGE FOR AN ACCOUNT IN A GENERAL LEDGER
CO4301 – Advanced Games Development Week 12 Using Trees
Presentation transcript:

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

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

How do Computers Perform Searches? The Method 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

Types of Searches? Some Examples 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

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.

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.

Number of Items in a listNumber of comparisons required in a binary search , ,048, ,073,741,82430 Binary Search

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