Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 1 Linear Search This algorithm allows the programmer.

Slides:



Advertisements
Similar presentations
Outline lecture Revise arrays Entering into an array
Advertisements

Standard Algorithms Find the highest number. ! Your name and today’s date ! Find the maximum Dim numbers(20) As Integer.
C. D. Toliver AP Statistics
Int 2 Multimedia Revision. Digitised Sound Analogue sound recorded from person, or real instruments.
Sorting CMSC 201. Sorting In computer science, there is often more than one way to do something. Sorting is a good example of this!
Designing Algorithms Csci 107 Lecture 4. Outline Last time Computing 1+2+…+n Adding 2 n-digit numbers Today: More algorithms Sequential search Variations.
STATISTICS. SOME BASIC STATISTICS MEAN (AVERAGE) – Add all of the data together and divide by the number of elements within that set of data. MEDIAN –
Standard Algorithms. 4 Standard Algorithms Input Validation Finding the Maximum / Minimum Counting Occurrences Linear Search.
Programming with Alice Computing Institute for K-12 Teachers Summer 2011 Workshop.
Standard Algorithms. Many algorithms appear over and over again, in program after program. These are called standard algorithms You are required to know.
The Hungarian algorithm for non-square arrays
Efficiency of Algorithms
Searching and Sorting SLA Computer Science 4/16/08 Allison Mishkin.
Designing Algorithms February 2nd. Administrativia Lab assignments will be due every Monday Lab access –Searles 128: daily until 4pm unless class in progress.
Designing Algorithms Csci 107 Lecture 3. Designing algorithms Last time –Pseudocode –Algorithm: computing the sum 1+2+…+n –Gauss formula for 1+2+…+n Today.
Designing Algorithms Csci 107 Lecture 3. Administrativia Lab access –Searles 128: daily until 4pm unless class in progress –Searles 117: 6-10pm, Sat-Sun.
Concept of Basic Time Complexity Problem size (Input size) Time complexity analysis.
Java vs. You.
CS 106 Introduction to Computer Science I 10 / 15 / 2007 Instructor: Michael Eckmann.
- SEARCHING - SORTING.  Given:  The array  The search target: the array element value we are looking for  Algorithm:  Start with the initial array.
What Does My Height Mean? By: Stefanie Del Rosso.
CMSC 104, Version 8/061L22Arrays1.ppt Arrays, Part 1 of 2 Topics Definition of a Data Structure Definition of an Array Array Declaration, Initialization,
CHAPTER 7: SORTING & SEARCHING Introduction to Computer Science Using Ruby (c) Ophir Frieder at al 2012.
Computation STRATEGIES
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory Pasewark & Pasewark.
1 Access Lesson 3 Creating Queries Microsoft Office 2010 Introductory.
Counting the Cost Recall linear search & binary search Number of items Worst CaseExpected Case Number of probes (comparisons) LinearBinary Linear Binary.
Mode Mean Range Median WHAT DO THEY ALL MEAN?.
WHAT IS AN INTEGER? Integers can be thought of as discrete, equally spaced points on an infinitely long number line. (Nonnegative integers (purple) and.
11 Finding Winners Using Arrays Session 8.2. Session Overview  Find out how the C# language makes it easy to create an array that contains multiple values.
1 By: Nour Hilal. Microsoft Access is a database software where data is stored in one or more Tables. A Database is a group of related Tables. Access.
Standard Algorithms –search for an item in an array –count items in an array –find the largest (or smallest) item in an array.
Arrays The concept of arrays Using arrays Arrays as arguments Processing an arrays data Multidimensional arrays Sorting data in an array Searching with.
1 Heaps and Priority Queues Starring: Min Heap Co-Starring: Max Heap.
Pasewark & Pasewark 1 Access Lesson 3 Creating Queries Microsoft Office 2007: Introductory.
Intro to Sorting Intro to Computer Science CS1510 Dr. Sarah Diesburg.
Einführung in die Programmierung Introduction to Programming Prof. Dr. Bertrand Meyer Chair of Software Engineering Complement to lecture 11 : Levenshtein.
Programming at a high level. Developing a Computer Program Programmer  Writes program in source code (VB or other language) Compiler  Converts source.
1 Heaps and Priority Queues v2 Starring: Min Heap Co-Starring: Max Heap.
3 – SIMPLE SORTING ALGORITHMS
Intermediate 2 Computing Unit 2 - Software Development.
R-Trees: A Dynamic Index Structure For Spatial Searching Antonin Guttman.
Math Message 1/6 of 30= 5/6 of 30 = 1/8 of 48 = 5/8 of 48 = 1/7 of 56 = 4/7 of 56 =
Sorting Sorting takes an unordered array and makes it an ordered one
Measures of Central Tendency Mean, Median, Mode, and Range.
 Software Development Life Cycle  Software Development Tools  High Level Programming:  Structures  Algorithms  Iteration  Pseudocode  Order of.
Writing Equations.
Forum Ratings: Aggregation The aggregate type defines how ratings are combined to form the final grade in the gradebook for that forum activity.
Visual Basic.NET BASICS Lesson 11 List Boxes, For Next Loops, and Label Settings.
11 PART 2 ARRAYS. 22 PROCESSING ARRAY ELEMENTS Reassigning Array Reference Variables The third statement in the segment below copies the address stored.
© T Madas Positive NumbersNegative Numbers Zero is not positive or negative.
Everyday Math Grade 4 – Lesson 2.5 Organizing and Displaying Data Copyright © 2010 Kelly Mott.
7 th Grade Math Vocabulary Word, Definition, Model Emery Unit 2.
Marr CollegeHigher Software DevelopmentSlide 1 Higher Computing Software Development Topic 4: Standard Algorithms.
Staff Guide Moodle Forums.
List Algorithms Taken from notes by Dr. Neil Moore & Dr. Debby Keen
Outline lecture Revise arrays Entering into an array
Goal: use counters to add integers
Standard Algorithms Higher Computing.
Mean, Median, and Mode.
Lesson 6.2 Mean, Median, Mode and Range
Standard Algorithms Input validation Finding the minimum
List Algorithms Taken from notes by Dr. Neil Moore
Triangle Inequalities
Mean, Median, and Mode.
Representing Integers
Integers.
Binary Search Counting
Grade 12 Essential Math Measurement and Statistics
Number Summaries and Box Plots.
Presentation transcript:

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 1 Linear Search This algorithm allows the programmer to search a list (an array) for a specific item of data. Each item in the list is compared with the data being searched for. When a ‘match’ is found then the position (in the array) is displayed.

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 2 Linear Search Let's say we have a list of 10 numbers in an array. (The top number only shows the position of each box in the array). We want to look for the number 64. We can see that it appears twice on the list, at positions 2 and

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 3 Linear Search 1.1ask for item being searched for 1.2get item being searched for 1.3FOR each item in the list 1.4IF item_in_list = item being searched for THEN 1.5report position in list 1.6END IF 1.7END FOR loop

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 4 Counting Occurrences This algorithm allows the programmer to count how many times an item of data appears in a list (an array). Each item in the list is compared with the item of data being counted. When a ‘match’ is found, one is added to the total number of occurrences.

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 5 Counting Occurrences Let's say we have a list of 10 numbers in an array. (The top number only shows the position of each box in the array). We want to count how many times the number 2 appears in the list. We can see that it appears three times in the list

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 6 Counting Occurrences 1.1set counter to zero 1.2ask for item being counted 1.3get item being counted 1.4FOR each item in the list 1.5IF item_in_list = item being counted THEN 1.6add 1 to the counter 1.7END IF 1.8END FOR loop 1.9display message showing number of occurrences (counter)

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 7 Finding the Maximum This algorithm allows the programmer to find the highest number in a list (an array).

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 8 Counting Occurrences Let's say we have a list of 10 numbers in an array. (The top number only shows the position of each box in the array). We want to find the highest number in the list. As you can see, it is the number

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 9 Counting Occurrences 1.1set ‘largest so far’ to the value of the first item in the list 1.2FOR each of the remaining items 1.3IF current item > largest so far THEN 1.4set ‘largest so far’ = current item 1.5END IF 1.6NEXT item in list 1.7display message showing ‘largest so far’

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 10 Finding the Minimum This algorithm allows the programmer to find the lowest number in a list (an array).

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 11 Counting Occurrences Let's say we have a list of 10 numbers in an array. (The top number only shows the position of each box in the array). We want to find the lowest number in the list. As you can see, it is the number

Higher Grade Computing Studies 4. Standard Algorithms Higher Computing Software Development S. McCrossan 12 Counting Occurrences 1.1set ‘smallest so far’ to the value of the first item in the list 1.2FOR each of the remaining items 1.3IF current item < smallest so far THEN 1.4set ‘smallest so far’ = current item 1.5END IF 1.6NEXT item in list 1.7display message showing ‘smallest so far’