Lecture # 30 Data Organization and Binary Search.

Slides:



Advertisements
Similar presentations
Database vocabulary. Data Information entered in a database.
Advertisements

Zabin Visram Room CS115 CS126 Searching
Searching for Data Relationship between searching and sorting Simple linear searching Linear searching of sorted data Searching for string or numeric data.
MATH 224 – Discrete Mathematics
CSE Lecture 3 – Algorithms I
HST 952 Computing for Biomedical Scientists Lecture 10.
MODULE 4 File and Folder Management. Creating file and folder A computer file is a resource for storing information, which is available to a computer.
Communicating Information: Web Design. It’s a big net HTTP FTP TCP/IP SMTP protocols The Internet The Internet is a network of networks… It connects millions.
Ver. 1.0 Session 5 Data Structures and Algorithms Objectives In this session, you will learn to: Sort data by using quick sort Sort data by using merge.
METU Department of Computer Eng Ceng 302 Introduction to DBMS Disk Storage, Basic File Structures, and Hashing by Pinar Senkul resources: mostly froom.
Objectives Learn how to implement the sequential search algorithm Explore how to sort an array using the selection sort algorithm Learn how to implement.
Introduction to Information Technology: Your Digital World © 2013 The McGraw-Hill Companies, Inc. All rights reserved.Using Information Technology, 10e©
What Is A Web Page? An Introduction to the Internet.
Chapter 8 ARRAYS Continued
Lecture # 31 Category Trees. Binary Trees 16 How many steps to reach a leaf? 4.
Introduction to Multimedia. The beginning ( History )… 1945 : “…a device in which one stores all his books, records and communications, and which is mechanized.
Mass Media Mass media is a broad concept. It includes
Illuminating Computer Science CCIT 4-6Sep
Lecture #32 WWW Search. Review: Data Organization Kinds of things to organize –Menu items –Text –Images –Sound –Videos –Records (I.e. a person ’ s name,
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 17 Disk Storage, Basic File Structures, and Hashing.
Lesson 1 -What is a Database? -Fields and Records
Chapter 16: Searching, Sorting, and the vector Type.
CPT: Search/ Computer Programming Techniques Semester 1, 1998 Objectives of these slides: –to discuss searching: its implementation,
ITEC 2620A Introduction to Data Structures
Today  Table/List operations  Parallel Arrays  Efficiency and Big ‘O’  Searching.
Chapter 19: Searching and Sorting Algorithms
Comparing AlgorithmsCSCI 1900 – Discrete Structures CSCI 1900 Discrete Structures Complexity Reading: Kolman, Sections 4.6, 5.2, and 5.3.
Database A database program is a piece of software to organize and sort information. It creates an electronic list of information that can be sorted very.
Data Structures IS 101Y/CMSC 101 Computational Thinking and Design Thursday, October 3, 2013 Marie desJardins University of Maryland, Baltimore County.
Searching Given a collection and an element (key) to find… Output –Print a message (“Found”, “Not Found) –Return a value (position of key ) Don’t modify.
Searching. RHS – SOC 2 Searching A magic trick: –Let a person secretly choose a random number between 1 and 1000 –Announce that you can guess the number.
C++ Programming: From Problem Analysis to Program Design, Second Edition Chapter 19: Searching and Sorting.
Array Processing.
DATA STRUCTURE & ALGORITHMS (BCS 1223) CHAPTER 8 : SEARCHING.
L. Grewe.  An array ◦ stores several elements of the same type ◦ can be thought of as a list of elements: int a[8]
Chapter 11 File Systems and Directories. 2 File Systems File: A named collection of related data. File system: The logical view that an operating system.
Search. Search issues How do we say what we want? –I want a story about pigs –I want a picture of a rooster –How many televisions were sold in Vietnam.
Simple Iterative Sorting Sorting as a means to study data structures and algorithms Historical notes Swapping records Swapping pointers to records Description,
CSM06 Information Retrieval Lecture 1a – Introduction Dr Andrew Salway
1 5. Abstract Data Structures & Algorithms 5.2 Static Data Structures.
ITEC 2620M Introduction to Data Structures Instructor: Prof. Z. Yang Course Website: ec2620m.htm Office: Tel 3049.
INDIANA STATE LIBRARY 2010 LSTA Grants The Project Budget Worksheet.
Review 1 Arrays & Strings Array Array Elements Accessing array elements Declaring an array Initializing an array Two-dimensional Array Array of Structure.
Sorting.
Sorting Algorithm Analysis. Sorting  Sorting is important!  Things that would be much more difficult without sorting: –finding a phone number in the.
Course Code #IDCGRF001-A 5.1: Searching and sorting concepts Programming Techniques.
1. Searching The basic characteristics of any searching algorithm is that searching should be efficient, it should have less number of computations involved.
Searching Topics Sequential Search Binary Search.
CS100 Final Review Study the quizzes Find out what you missed on the midterms.
INFORMATION STROAGE AND RETRIEVAL SYSTEM By Ms. Preeti Patel Lecturer School of Library And Information Science DAVV, Indore
VISUAL C++ PROGRAMMING: CONCEPTS AND PROJECTS Chapter 8A Binary Search (Concepts)
Chapter 16: Searching, Sorting, and the vector Type.
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.
Creating a Database Microsoft Access.
Searching Given a collection and an element (key) to find… Output
Algorithmic Efficency
The Database Application
Sorting by Tammy Bailey
INTRODUCTION TO INFORMATION TECHNOLOGY Your Digital World
CSc 110, Spring 2017 Lecture 39: searching.
EXPLORING COMPUTER SCIENCE Journal Entries, Portfolio Entries, And Check Your Understanding Unit 2 – Strand 2 Problem Solving This unit focuses on.
Binary Search and Intro to Sorting
Searching: linear & binary
ITEC 2620M Introduction to Data Structures
CPS120: Introduction to Computer Science
CPS120: Introduction to Computer Science
An Introduction to the Internet
CMPT 225 Lecture 10 – Merge Sort.
Presentation transcript:

Lecture # 30 Data Organization and Binary Search

Data Organization

Problem Huge amounts of information How do I find –Information that I know I want –Information related to what I want How do I understand –Particular pieces of information –The whole collection of information

Limitations Screen space Network bandwidth –Bandwidth - how much information can be transmitted per second Human attention

Kinds of things to organize Menu items –MS Word - about 150 menu items Text –Pages in a book –Documents on the WWW - gazillions Images –All of the pictures created in a commercial advertising company

Kinds of things to organize Sounds –Sound tracks to all TV and Radio news broadcasts Video –A complete collection of classic movies Structured information (records) –People –Cars –Students –Electronic appliance parts

A question of scale 10 things 100 things - menu 1,000 things - files on your computer 10,000 things - students at a university 1,000,000 things - books in a library gazillion things - WWW pages

Three ways to find things Lists –arrays Trees –organize in to categories Search –describe what you want and have the computer find it

The Phone Book Challenge How long will it take to find “ Bill Lund ” in the BYU Directory? How long will it take to find “ ” in the BYU Directory?

What Algorithm did you use to search the phone book? Where did you start? How many steps did it take? Is there a more efficient way?

Binary search - for “ Goodrich ”

Lower = 0 Upper = 10 Guess = (0+10)/2 = 5

Binary search - for “ Goodrich ” Lower = 0 Upper = 5 Guess = (0+5)/2 = 2

Binary search - for “ Goodrich ” Lower = 2 Upper = 5 Guess = (2+5)/2 = 3

Binary search - for “ Goodrich ” Lower = 3 Upper = 5 Guess = (3+5)/2 = 4

Binary search If there are 64 things in a list, how many times can you divide that list in half? –32, 16, 8, 4, 2, 1 6 times

Binary search If there are 1024 things in a list, how many times can you divide that list in half? –512, 256, 128, 64, 32, 16, 8, 4, 2, 1 10 times

Binary search If the size of the list doubles, how many more steps are required in a binary search? 1

Binary search If there are N items in a list then binary search takes log 2 (N) steps

Binary search Estimating log 2 (N) –Count the number of digits and multiply by –4*2.5 = 10 steps 1,000,000 –7*2.5 = steps 1,000,000,000 –10*2.5= 25 steps

Provo/Orem phone book How long to find “ Bill Lund? ” ~ 5000 in the BYU Directory –Log 2 (5000) approx 4*2.5 = 10 steps

How to find a phone number –1 step –11 steps Average? –5 steps Average N? –N/2

Provo/Orem phone book How many steps to find a phone number? –5,000/2 = 2,500 average How can we improve this?

Sort the phone book by phone number What if I want to search on both name and number?

Using an Index Last NamePhone number

Using an Index Last NamePhone number Anderson

Using an Index Last NamePhone number Anderson, Bilinski

Using an Index Last NamePhone number Anderson, Bilinski, Clark

Using an Index Last NamePhone number Anderson, Bilinski, Clark, Garcia

Using an Index Last NamePhone number

Using an Index Last NamePhone number ,

Using an Index Last NamePhone number , ,

Using an Index Last NamePhone number , , ,

Search for Goodrich Last Name Lower = 0 Upper = 10 Guess = 5 lower

Search for Goodrich Last Name Lower = 0 Upper = 5 Guess = 2 above

Search for Goodrich Last Name Lower = 2 Upper = 5 Guess = 3 above

Search for Goodrich Last Name Lower = 3 Upper = 5 Guess = 4 above

Search for Lower = 0 Upper = 10 Guess = 5 above Phone number

Search for Lower = 5 Upper = 10 Guess = 7 below Phone number

Search for Lower = 5 Upper = 7 Guess = 6 MATCH Phone number

Using an Index Last NamePhone number What about first name or city? –another index

Data Organization Summary What are we organizing for? Scale –10 - 1, ,000, ,000,000,000 Lists –Unsorted (N/2) –Sorted Log 2 (N) count the digits and multiply by 2.5 To access in many ways –Use many indices into the same data