CPSC 171 Introduction to Computer Science Algorithm Discovery and Design.

Slides:



Advertisements
Similar presentations
CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
Advertisements

CS107 Introduction to Computer Science Lecture 2.
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
CPSC 171 Introduction to Computer Science Efficiency of Algorithms.
Computer Science 101 Overview of Algorithms. Example: Make Pancakes Prepare batter Beat 2 eggs Add 1 tablespoon of brown sugar Add 1 cup of milk Add 2.
Designing Algorithms Csci 107 Lecture 4. Outline Last time Computing 1+2+…+n Adding 2 n-digit numbers Today: More algorithms Sequential search Variations.
ITEC113 Algorithms and Programming Techniques
Chapter 1: An Introduction to Computer Science Invitation to Computer Science, C++ Version, Third Edition.
Chapter 4 Repetitive Execution. 2 Types of Repetition There are two basic types of repetition: 1) Repetition controlled by a counter; The body of the.
CS107 Introduction to Computer Science
What is an algorithm? Informally: An Algorithm is a step by step method for solving a problem. It’s purpose is to break a larger task down so that each.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
Designing Algorithms February 2nd. Administrativia Lab assignments will be due every Monday Lab access –Searles 128: daily until 4pm unless class in progress.
CS107 Introduction to Computer Science Lecture 2.
Chapter 2 The Algorithmic Foundations of Computer Science
Unit 171 Algorithms and Problem Solving  Introduction  Algorithm Design  Algorithm Properties  Algorithm Control Flow  Examples  Comparing Algorithms.
CHAPTER 2 CS
Designing Algorithms Csci 107 Lecture 3. Administrativia Lab access –Searles 128: daily until 4pm unless class in progress –Searles 117: 6-10pm, Sat-Sun.
Chapter 2: Design of Algorithms
CS10051 Section 601 Introduction to Computer Science Fall 08 Dr. Angela Guercio Dr. C. David Hunter.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Designing Algorithms Csci 107 Lecture 4.
Chapter 2: Algorithm Discovery and Design
Computer Science: A Structured Programming Approach Using C1 Objectives ❏ To understand basic loop concepts: ■ pretest loops and post-test loops ■ loop.
Chapter 8: Introduction to High-level Language Programming Invitation to Computer Science, C++ Version, Third Edition.
Chapter 2: Algorithm Discovery and Design
Chapter 2: Algorithm Discovery and Design
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
Adapted from slides by Marie desJardins
CPSC 171 Introduction to Computer Science 3 Levels of Understanding Algorithms More Algorithm Discovery and Design.
Algorithmic Problem Solving CMSC 201 Adapted from slides by Marie desJardins (Spring 2015 Prof Chang version)
计算机科学概述 Introduction to Computer Science 陆嘉恒 中国人民大学 信息学院
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science, C++ Version, Third Edition.
Invitation to Computer Science 6th Edition
Invitation to Computer Science, Java Version, Second Edition.
CSE 102 Introduction to Computer Engineering What is an Algorithm?
Selection Control Structures. Simple Program Design, Fourth Edition Chapter 4 2 Objectives In this chapter you will be able to: Elaborate on the uses.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
CPSC 171 Introduction to Computer Science More Algorithm Discovery and Design.
Pseudocode. Simple Program Design, Fourth Edition Chapter 2 2 Objectives In this chapter you will be able to: Introduce common words, keywords, and meaningful.
Pseudocode Simple Program Design Third Edition A Step-by-Step Approach 2.
ITEC113 Algorithms and Programming Techniques
Dale Roberts 1 Program Control - Algorithms Department of Computer and Information Science, School of Science, IUPUI CSCI N305.
Pseudocode Algorithms Using Sequence, Selection, and Repetition Simple Program Design Third Edition A Step-by-Step Approach 6.
CSCI-100 Introduction to Computing
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
More Python!. Lists, Variables with more than one value Variables can point to more than one value at a time. The simplest way to do this is with a List.
Agenda Perform Quiz #1 (20 minutes) Loops –Introduction / Purpose –while loops Structure / Examples involving a while loop –do/while loops Structure /
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
Invitation to Computer Science 5 th Edition Chapter 2 The Algorithmic Foundations of Computer Science.
INVITATION TO Computer Science 1 11 Chapter 2 The Algorithmic Foundations of Computer Science.
CMPSC 16 Problem Solving with Computers I Spring 2014 Instructor: Tevfik Bultan Lecture 4: Introduction to C: Control Flow.
Lecture 3: Developing Procedural Thinking (How to think like a programmer) B Burlingame 16 Feb 2016.
Flow Control in Imperative Languages. Activity 1 What does the word: ‘Imperative’ mean? 5mins …having CONTROL and ORDER!
Chapter 2: Algorithm Discovery and Design Invitation to Computer Science.
Program design Program Design Process has 2 phases:
Think What will be the output?
Topics discussed in this section:
Lecture 2: Introduction to Algorithms
COMS W1004 Introduction to Computer Science and Programming in Java
Chapter 6 Repetition Objectives ❏ To understand basic loop concepts:
Introduction to pseudocode
MSIS 655 Advanced Business Applications Programming
Algorithm Discovery and Design
Iteration: Beyond the Basic PERFORM
Algorithm Discovery and Design
Computer Science Core Concepts
Discovery and Design of Algorithms
Presentation transcript:

CPSC 171 Introduction to Computer Science Algorithm Discovery and Design

Lab Hours, Colton 106 Sunday: Matt Young Monday: Will Mooney Tuesday: Cody Depew Wednesday: Christian Ebinger Thursday: Stefan Maurer Lab will be open 8-10pm starting Monday night, Sept. 7

Reading Assignment Chapter 1 in Textbook Homework Assignment page 34 of Textbook Problems 5,7,8,9,13 Due Sept 4 at beginning of class

Problem 3 Page 34 Read problem in book Follow along on board

An Algorithm is A well-ordered collection of Unambiguous and Effectively computable operations that, when executed Produces a result and Halts in a finite amount of time Textbook definition

Representing Algorithms How do we represent algorithms? English Programming Language We will start with pseudocode and later will look at various programming languages.

Pseudocode Set of English Constructs designed to resemble statements in programming languages Steps presented in structured manner Simple, Highly readable

Constructs We Will Use Sequential operations to carry out computation, input, and output. Conditional operations. Iterative operations.

Sequential Operations computation  Set the value of X to 3.  Assign X a value of A + B.  X=2 - C.  Set the value of Name to the first person's name. input  Get a value for X, Y, and Z.  Input values for A1, A2,..., Am.  Read X, Y, and Carry. output  Output the value of X.  Print values for X, Y, and Carry.  Print the message, "Error".

Example Algorithm (Sequential) Figure 2.3 Algorithm for Computing Average Miles per Gallon

Practice Write an algorithm in pseudocode to: Get the radius of a circle as input and output the circumference and area of the circle

Conditional Operation If “a true/false condition” is true then first set of algorithmic operations Else second set of algorithm operations Notice the indentation

Example Algorithm (conditionals) Figure 2.5 Second Version of the Average Miles per Gallon Algorithm

Practice Modify your algorithm to print “large circle” if the circumference is greater than 100 and “small circle” if it is equal to or less than 100.

Conditional Operation Picture true-false statement truefalse operation false branch true branch Note: either branch can be missing

true-false statement truefalse operation false branch true branch Note: either branch can be missing Conditional Operation Picture

true-false statement truefalse operation false branch true branch Note: either branch can be missing Conditional Operation Picture

Iterative Operations Set count to 5 While count < 4 Add 1 to count Print count stop Set count to 5 Do Add 1 to count Print count While count < 4 stop Notice when the continuation condition is checked Pretest loopPosttest loop

Infinite Loops Set count to 0 While count >= 0 Add 1 to count Print count stop

Iteration Operation Picture true-false statement true-false statement false true operation false operation while loop Do/while loop

Figure 2.7 Third Version of the Average Miles per Gallon Algorithm Example Algorithm (iteration)

Practice Write an algorithm that gets as input a single data value, x, and outputs the three values x 2, sin x, 1/x. This process should repeat until the input value for x is equal to 99.

Summary of Operation Types for Algorithms Sequential operations to carry out computation, input, and output. Conditional operations. Iterative operations.

There is a theorem in theoretical computer science that proves that these operations are sufficient to represent ANY algorithm! Algorithms are used to do everything you see on a computer! Do word processing. Fly NASA probes to the planets. Run the international telephone switching system. Create CAT scan images. Process your pay checks. Run computer games. Etc.