Lecture 81 Table Search (1) 02ART HISTORY 04BIOLOGY 19CHEMISTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE 43MANAGEMENT 49MARKETING 54STATISTICS.

Slides:



Advertisements
Similar presentations
Databases. A database program can be used to:  sort a file into a different order  Maintain contact with clients  search through the records for a.
Advertisements

CSE Lecture 3 – Algorithms I
Hashing as a Dictionary Implementation
Concepts of Database Management Sixth Edition
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.
Insertion sort, Merge sort COMP171 Fall Sorting I / Slide 2 Insertion sort 1) Initially p = 1 2) Let the first p elements be sorted. 3) Insert the.
Chapter 11 Sorting and Searching. Topics Searching –Linear –Binary Sorting –Selection Sort –Bubble Sort.
Introduction to Structured Query Language (SQL)
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
Searches & Sorts V Deena Engel’s class Adapted from W. Savitch’s text An Introduction to Computers & Programming.
1 Lecture 9  Arrays  Declaration  Initialization  Applications  Pointers  Declaration  The & and * operators  NULL pointer  Initialization  Readings:
E.G.M. Petrakissearching1 Searching  Find an element in a collection in the main memory or on the disk  collection: (K 1,I 1 ),(K 2,I 2 )…(K N,I N )
 2003 Prentice Hall, Inc. All rights reserved Sorting Arrays Sorting data –Important computing application –Virtually every organization must sort.
CSCI 5708: Query Processing I Pusheng Zhang University of Minnesota Feb 3, 2004.
Copyright © Cengage Learning. All rights reserved. CHAPTER 11 ANALYSIS OF ALGORITHM EFFICIENCY ANALYSIS OF ALGORITHM EFFICIENCY.
Chapter 3: The Efficiency of Algorithms
Concepts of Database Management Sixth Edition
Queries and SQL in Access Please use speaker notes for additional information!
12-1 COBOL for the 21 st Century Nancy Stern Hofstra University Robert A. Stern Nassau Community College James P. Ley University of Wisconsin-Stout (Emeritus)
With Microsoft Office 2007 Introductory© 2008 Pearson Prentice Hall1 PowerPoint Presentation to Accompany GO! with Microsoft ® Office 2007 Introductory.
Database System Concepts, 5th Ed. ©Silberschatz, Korth and Sudarshan See for conditions on re-usewww.db-book.com Chapter 13: Query Processing.
PowerPoint Presentation: Richard H. Baum, Ph.D. DeVry Institute of Technology 9th Edition Structured COBOL Programming Nancy Stern Hofstra University Robert.
Week 11 Introduction to Computer Science and Object-Oriented Programming COMP 111 George Basham.
12- 1 Chapter 12.  Single-Level OCCURS Clauses  Processing Data Stored in Array  Using OCCURS Clause for Table Handling  Use of SEARCH Statement 
SEARCHING UNIT II. Divide and Conquer The most well known algorithm design strategy: 1. Divide instance of problem into two or more smaller instances.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
DATA STRUCTURE & ALGORITHMS (BCS 1223) CHAPTER 8 : SEARCHING.
SEARCHING. Vocabulary List A collection of heterogeneous data (values can be different types) Dynamic in size Array A collection of homogenous data (values.
C# PROGRAMMING Searching & Sorting. Objective/Essential Standard Essential Standard 3.00 Apply Advanced Properties of Arrays Indicator 3.03 Apply procedures.
SEARCHING.  This is a technique for searching a particular element in sequential manner until the desired element is found.  If an element is found.
1 Chapter 14 - Sorting System Concepts –Sort key Major Key (Primary) Minor Key (Secondary) –Sort sequence Ascending - Low to high Descending – High to.
Structure Query Language SQL. Database Terminology Employee ID 3 3 Last name Small First name Tony 5 5 Smith James
Concepts of Database Management Seventh Edition
Chapter 12 (part 2) Table Handling and Search Techniques.
More about Databases. Data Entry through Forms Table View (Data sheet view) is useful for data entry of new records But sometimes customization would.
1 Chapter – 12 Table Lookups Table Codes –Expanded Values –Types of Codes Numeric Alphabetic Alphanumeric.
Searching Tables.. Creating Pre-filled Tables A B C D E F G H I J K L ABCDEFGHIJKLM NOPQRSTUVWXYZ 01 LetterTable. 02 TableValues. 03 FILLER PIC X(13)
Microsoft Office Illustrated Introductory, Premium Edition Using Tables and Queries.
Microsoft Office XP Illustrated Introductory, Enhanced Tables and Queries Using.
Lecture 1- Query Processing Advanced Databases Masood Niazi Torshiz Islamic Azad university- Mashhad Branch
Database Fundamental & Design by A.Surasit Samaisut Copyrights : All Rights Reserved.
12- 1 Chapter 12.  Single-Level OCCURS Clauses  Processing Data Stored in Array  Using OCCURS Clause for Table Handling  Use of SEARCH Statement 
Review 1 Arrays & Strings Array Array Elements Accessing array elements Declaring an array Initializing an array Two-dimensional Array Array of Structure.
Objectives At the end of the class, students are expected to be able to do the following: Understand the searching technique concept and the purpose of.
1 Review for test 2 Chapters 7, 8, 9, 11, What is wrong with the following paragraphs? PARA-A. PARA-B. ADD A TO B MOVE 0 TO X PERFROM PARA-A PERFORM.
Sorting and Searching. Selection Sort  “Search-and-Swap” algorithm 1) Find the smallest element in the array and exchange it with a[0], the first element.
Chapter 8 Sorting and Searching Goals: 1.Java implementation of sorting algorithms 2.Selection and Insertion Sorts 3.Recursive Sorts: Mergesort and Quicksort.
Databases.  A database is simply a collection of information stored in an orderly manner.  A database can be as simple as a birthday book, address book.
DAY 16: MICROSOFT ACCESS – CHAPTER 2 Madhuri Siddula October 8, 2015.
One & Two dimensional Tables Cont.. Table of Major Codes 02ART HISTORY 04BIOLOGY 19CHEMESTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE.
Databases Letts Chapter 11. A database program can be used to:  sort a file into a different order;  search through the records for a matching string.
Sorting and Searching by Dr P.Padmanabham Professor (CSE)&Director
Lesson 13 Databases Unit 2—Using the Computer. Computer Concepts BASICS - 22 Objectives Define the purpose and function of database software. Identify.
CAPTER 6 SEARCHING ALGORITHM. WHAT IS SEARCHING Process of finding an item in an array Two ways to find an item By position / By value.
Searching Sequential Search Binary Search. Sequential Search Sequential search is to look into the key one after another until the target is found If.
Lecture 9COMPSCI.220.FS.T Lower Bound for Sorting Complexity Each algorithm that sorts by comparing only pairs of elements must use at least 
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.
Distribution of Marks For Second Semester Internal Sessional Evaluation External Evaluation Assignment /Project QuizzesClass Attendance Mid-Term Test Total.
7 1 Database Systems: Design, Implementation, & Management, 7 th Edition, Rob & Coronel 7.6 Advanced Select Queries SQL provides useful functions that.
CS4432: Database Systems II
Copyright © 2015, 2012, 2009 Pearson Education, Inc., Publishing as Addison-Wesley All rights reserved. Chapter 8: Searching and Sorting Arrays.
VOCAB REVIEW. A field that can be computed from other fields Calculated field Click for the answer Next Question.
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.
Chapter 9: Sorting and Searching Arrays
LOGICAL CONTROL STRUCTURES (chp. 8)
Searching and Sorting Arrays
From the ASCII table… Symbol Decimal Binary A B 66
Searching and Sorting Arrays
Presentation transcript:

lecture 81 Table Search (1) 02ART HISTORY 04BIOLOGY 19CHEMISTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE 43MANAGEMENT 49MARKETING 54STATISTICS 05 COURSES OCCURS 10 TIMES INDEXED BY ARR-SUB. 10 CALL-NUM PIC SUBJECT PIC X(15)

lecture 82 Table Search (2) What subject has value 39? Find a record in the table that matches a query –The search key is the entry value we search on What algorithm will find this record?

lecture 83 Seqential Search 02ART HISTORY 04BIOLOGY 19CHEMISTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE 43MANAGEMENT 49MARKETING 53STATISTICS 39 1st try 2nd try 3rd try 4th try 5th try 6th try 7th try FINANCE Match

lecture 84 Search Key : CALL-NUM MOVE “N” ITEM-FOUND. PERFORM VARYING ARR-SUB FROM 1 BY 1 UNTIL ITEM-FOUND = “Y” OR ARR-SUB = 10 IF CALL-NUM (ARR-SUB) = 39 MOVE “Y” TO ITEM-FOUND END-PERFORM

lecture 85 SEARCH Statement (1) SET ARR-SUB TO 1. SEARCH COURSES AT END MOVE “N” TO ITEM-FOUND WHEN CALL-NUM (ARR-SUB) = 39 MOVE “Y” TO ITEM-FOUND.

lecture 86 SEARCH Statement (2) SEARCH ident-1 VARYING {ident-2 | index-name} { AT END statement-1} { WHEN cond-1 statement-2} END-SEARCH. Sequential search starts at the entry denoted by the current index value AT END is executed when the end of the table is reached One or more WHEN clauses allowed –When any of one them are satisfied the search ends VARYING clause names the index –May associate more than one index with the table –Uses the first index named in the INDEX BY clause if omitted

lecture 87 Binary Search 02ART HISTORY 04BIOLOGY 19CHEMISTRY 21CIVIL ENGINEERING 24COMP INF SYS 32ECONOMICS 39FINANCE 43MANAGEMENT 49MARKETING 53STATISTICS 39 1st try FINANCE Match 2nd try 3rd try

lecture 88 SEARCH Statement (3) 05 COURSES OCCURS 10 TIMES ASCENDING KEY IS CALL-NUM INDEXED BY ARR-SUB. 10 CALL-NUM PIC SUBJECT PIC X(15) SEARCH ALL COURSES AT END MOVE “N” TO ITEM-FOUND WHEN CALL-NUM (ARR-SUB) = 39 MOVE “Y” TO ITEM-FOUND.

lecture 89 SEARCH Statement (4) L# table-name OCCURS integer TIMES {ASCENDING/DESCENDING} KEY IS ident-1 INDEXED BY {index-1 …} SEARCH ALL table-name { AT END statement-1} { WHEN statement-2} END-SEARCH.

lecture 810 SEARCH Statement (5) For Binary Search use SEARCH ALL The entries in the table should be sorted in ascending/descending order on the key field AT END is executed if no entry satisfies the condition The search ends if the WHEN clause is satisfied

lecture 811 Binary Search : Worst Case NUMBER OF ELEMENTSMAXIMUM NUMBER OF COMPARISONS (less than 2 4 ) (less than 2 5 ) (less than 2 6 ) (less than 2 7 ) (less than 2 8 ) (less than 2 9 ) (less than 2 10 ) (less than 2 11 ) (less than 2 12 )

lecture 812 Sort (1) NAME YEARMAJOR Smith1Liberal arts Jones4Engineering Adams3Business Howe2Liberal arts Frank1 Engineering Zev4Business Benjamin 4Business Grauer3Liberal arts Crawford 2Engineering Deutsch4Business Makoske 1Business Unsorted Data

lecture 813 Sort (2) Primary Key: Name (Ascending) NAME YEARMAJOR Adams3Business Benjamin 4Business Crawford 2Engineering Deutsch4Business Frank1 Engineering Grauer3Liberal arts Howe2Liberal arts Jones4Engineering Makoske 1Business Smith1Liberal arts Zev4Business Sorted Data, One Key

lecture 814 Sort (3) Sorted Data, Two Keys Primary key: Year (descending) Secondary key: Name (ascending) NAME YEARMAJOR Benjamin 4Business Deutsch4Business Jones4Engineering Zev4Business Adams3Business Grauer3Liberal arts Crawford 2Engineering Howe2Liberal arts Frank1 Engineering Makoske 1Business Smith1Liberal arts

lecture 815 Sort (4) Primary Key: major (Ascending) Secondary Key: year (Descending) Tertiary Key: name (Ascending) NAMEYEARMAJOR Benjamin 4Business Deutsch4Business Zev4Business Adams3Business Makoske 1Business Jones4Engineering Crawford 2Engineering Frank1 Engineering Grauer3Liberal arts Howe2Liberal arts Smith1Liberal arts Sorted Data, Three Keys

lecture 816 ASCII Table (space) “(quotation mark) $(currency symbol) ‘(apostrophe) ((left parenthesis) )(right parenthesis) *(asterisk) +(plus symbol),(comma) -(hyphen, minus symbol).(period, decimal point) /(slash) 0 through 9 ;(semicolon) (greater than) A through Z (upper case) a through z (lower case)

lecture 817 SORT : A Table SORT table-name { ON ASCENDING/DESCENDING KEY ident-1… } { WITH DUPLICATES IN ORDER}. ASCENDING/DESCENDING may be defined at the table declaration –Key fields at the SORT statement override DUPLICATES clause order by table order