Algorithms Algorithms are a familiar idea. Our goal is to learn to specify them right so someone or something else does the work.

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

DT Coursework By D. Henwood.
Nested if-else Statements.  Should be indented to make the logic clear.  Nested statement executed only when the branch it is in is executed. For example,
Copyright © 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Algorithmic Thinking What’s the Plan? lawrence snyder c h a p t e r 10.
Process Design (Specification)
Introduction to Flowcharting
Flow Control Analysis & Design Tool: Flowcharts
Clearly Visual Basic: Programming with Visual Basic 2008 Chapter 9 Decisions, Decisions, Decisions.
ME 142 Engineering Computation I Fundamentals of Procedural Computer Programming.
II N T R O D U C T I O N PP R E T E S T DD E S I G N I N G A L G O R I T H M DD E S I G N I N G F L O W C H A R T GG E N E R A L R U L E S F.
8 Algorithms Foundations of Computer Science ã Cengage Learning.
Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the five essential properties of an algorithm.
Chapter 10 Algorithmic Thinking. Copyright © 2013 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Learning Objectives List the five essential.
Chapter 10 What's The Plan?: Algorithmic Thinking.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Introduction to Computers CS Dr. Zhizhang Shen Chapter 10: How to.
© Janice Regan, CMPT 102, Sept CMPT 102 Introduction to Scientific Computer Programming The software development method algorithms.
Chapter 2- Visual Basic Schneider
CS 536 Spring Global Optimizations Lecture 23.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts and Debugging.
Prof. Fateman CS 164 Lecture 221 Global Optimization Lecture 22.
1 CSE1301 Computer Programming: Lecture 15 Flowcharts, Testing and Debugging.
Prof. Bodik CS 164 Lecture 16, Fall Global Optimization Lecture 16.
1 Chapter 2 Problem Solving Techniques INTRODUCTION 2.2 PROBLEM SOLVING 2.3 USING COMPUTERS IN PROBLEM SOLVING : THE SOFTWARE DEVELOPMENT METHOD.
Game city International Starting on the road to programming. This project is all about learning how to program using scratch and other languages. The aim.
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Programming Logic and System Analysis
Algorithm & Flowchart.
Introduction to Programming Lecture Number:. What is Programming Programming is to instruct the computer on what it has to do in a language that the computer.
High level & Low level language High level programming languages are more structured, are closer to spoken language and are more intuitive than low level.
Algorithms Algorithms are a familiar idea. Our goal is to learn to specify them right so someone or something else does the work.
Some quotes…. I really hate this damned machine I wish that they would sell it. It never does quite what I want But only what I tell it. ~Anon These machines.
Chapter 13 Recursion. Learning Objectives Recursive void Functions – Tracing recursive calls – Infinite recursion, overflows Recursive Functions that.
12-CRS-0106 REVISED 8 FEB 2013 KUG1C3 Dasar Algoritma dan Pemrograman.
Problem Solving Techniques. Compiler n Is a computer program whose purpose is to take a description of a desired program coded in a programming language.
Flowcharts.
Activity diagrams. Introduction ● Activity diagrams are a behavioural model that represent the dynamics of the system. ● An activity diagram is essentially.
Algorithms & Flowchart
03/11/20151 System Development Lifecycle Design. 203/11/2015 Learning Objectives Consider the relevance and timeliness of data. Describe: The processes.
Topics: Function Intitution Algorithm Example Function Definition (and Indentation) Function Call Naming and Binding Local Variables Function Arguments.
Copyright © 2008 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Fluency with Information Technology Third Edition by Lawrence Snyder Chapter.
What's The Plan? Algorithmic Thinking Step-by-step directions for whatever someone, or the computer, needs to do © 2004 Lawrence Snyder.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
© 2006 Pearson Addison-Wesley. All rights reserved 2-1 Chapter 2 Principles of Programming & Software Engineering.
Chapter 10 Algorithmic Thinking. Learning Objectives Explain similarities and differences among algorithms, programs, and heuristic solutions List the.
CS 173, Lecture B Tandy Warnow. Topics for today Reminder about Examlet on Tuesday My office hours next week: –Tuesday 2-3 PM and Thursday 3-4 PM Office.
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
ALGORITHMS AND FLOWCHARTS. Why Algorithm is needed? 2 Computer Program ? Set of instructions to perform some specific task Is Program itself a Software.
Learning Objective To be able to… Understand flow chart symbols Complete and correct flow chart algorithms Create a program based on a flow chart.
Lawrence Snyder University of Washington, Seattle © Lawrence Snyder 2004.
Turing Machines Sections 17.6 – The Universal Turing Machine Problem: All our machines so far are hardwired. ENIAC
Problem Solving Flowcharts. Flowcharts Introduction  Flowcharts allow us to create a visual representation of a solution to a problem DRAW  With flowcharts,
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
Program Design & Development EE 201 C7-1 Spring
Combinatorial Counting
Numbering System TODAY AND TOMORROW 11th Edition
Unit# 9: Computer Program Development
Introduction to Algorithms
INFO/CSE 100, Spring 2005 Fluency in Information Technology
CSCI 1250 Information Technologies
Chapter 2- Visual Basic Schneider
ME 142 Engineering Computation I
Flowcharting & Algorithms
Chapter 10: Algorithm TECH Prof. Jeff Cheng.
What's The Plan?: Algorithmic Thinking
Start or end of algorithm: Action/process step:
Basic Concepts of Algorithm
What's The Plan?: Algorithmic Thinking
What's The Plan?: Algorithmic Thinking
CS 173, Lecture B Tandy Warnow
Presentation transcript:

Algorithms Algorithms are a familiar idea. Our goal is to learn to specify them right so someone or something else does the work

Previous Algorithms Algorithm, a precise, systematic method to produce a specified result We have seen algorithms already... Placeholder technique is an algorithm with an easy specification: longStringWithShortStringInIt  placeholder ShortString   placeholder  longStringWithShortStringInIt Not every process is an algorithm -- debugging

Properties of Algorithms For an algorithm to be well specified it must have … Inputs specified Outputs specified Definiteness Effectiveness Finiteness

Five Essential Properties of Algorithms Inputs specified -- data that will be transformed Outputs specified – the intended result Definiteness – must specify every step Effectiveness – steps can be executed (mechanically, no special talent) Finiteness – it must eventually stop

Programs vs Algorithms A program is an algorithm specialized to a particular situation  Algorithm: longStringWithShortStringInIt  placeholder ShortString   placeholder  longStringWithShortStringInIt  Program:   #    #  

Alphabetize CDs 1. Def Artist_of Use Artist_of to refer to the group name 2. Pick Alpha Decide which end of rack is to be start of alphabetic sequence, and call the first slot alpha 3. Pick Beta Call the slot next to alpha, beta 4. Exchange If Artist_of the CD in the alpha slot is later in the alphabet than the Artist_of the CD in the beta slot, interchange the CDs, otherwise continue on 5. More Betas? If a slot follows beta slot, begin calling it the beta slot and go to step 4, otherwise continue on 6. More Alphas? If two slots follow the alpha slot, begin calling the next one the alpha slot and the one following it the beta slot; go to step 4; otherwise stop Wynette Beethoven Spoon Hampton Pearl Jam

Flow Chart Define Artist_Of Select starting end; name it alpha Call beta the slot adjacent to alpha Is Artist_Of CD in alpha slot later than Artist_Of CD in beta slot Is there a slot following the beta slot? Are there 2 slots following alpha? Interchange CDs in alpha & beta Begin calling next slot beta Advance alpha to next slot & slot after it beta N Y N NStop Y Y Start

Abstraction Abstraction means removing an idea or process form a situation Beta sweep -- while alpha points to a fixed slot, beta sweeps through slots following alpha, interchanging as necessary The beta sweep is a concept removed based on our understanding of the operation of the algorithm   Beta Sweep

Flow Chart Define Artist_Of Select starting end; name it alpha Call beta the slot adjacent to alpha Is Artist_Of CD in alpha slot later than Artist_Of CD in beta slot Is there a slot following the beta slot? Is there a pair of slots following alpha? Interchange CDs in alpha & beta Begin calling next slot beta Advance alpha to next slot & slot after it beta N Y N NStop Y Y Start

The Beta Sweep By abstracting we can analyze parts of an algorithm …  The beta sweep has 4 properties: Exhaustive -- it considers all CDs after alpha Non-redundant -- no slot pair is checked twice Progressive -- the alphabetically earliest CD considered so far is always in the alpha slot Effective -- at completion, the alphabetically earliest CD from alpha to end is in alpha slot These properties apply only to Alphabetize CDs

Alpha Sweep The alpha sweep... Process of sweeping through all of the CDs (but the last) performing the beta sweep Exhausitve -- considers all but last CD Non-redundant -- a slot is alpha only once Progressive -- when beta sweep completes the alphabetically next CD in alpha Complete -- when last beta sweep is done the last slot’s CD is later than next to last slot Effective -- the alpha sweep alphabetizes

Figure The steps of Alphabetize CDs. A snapshot of the CD rack is shown at the completion of each instruction. The pair of numbers in the boxes gives the instruction from the algorithm and step in the overall execution just completed. Figure Flowchart of Alphabetize CDs. Operations are shown in rectangles; decisions are shown in diamonds. Arrows indicate the sequencing of the operations.

Figure 10.2 (continued). The steps of Alphabetize CDs. A snapshot of the CD rack is shown at the completion of each instruction. The pair of numbers in the boxes gives the instruction from the algorithm and step in the overall execution just completed. Figure Flowchart of Alphabetize CDs. Operations are shown in rectangles; decisions are shown in diamonds. Arrows indicate the sequencing of the operations.

Summary We figure out most algorithms on our own, abstracting from specific cases Also we abstract parts of an algorithm or program to understand them  Thinking of how the program works and reasoning about its properties allows us to know why an algorithm works … and then we can let the computer do it