CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes.

Slides:



Advertisements
Similar presentations
Introduction to Programming
Advertisements

CS107 Introduction to Computer Science Lecture 3, 4 An Introduction to Algorithms: Loops.
CS107 Introduction to Computer Science Lecture 2.
CS107: Introduction to Computer Science Lecture 2 Jan 29th.
Introduction to Flowcharting
PSEUDOCODE & FLOW CHART
Chapter 3 IFTHENELSE Control Structure © 2008 Pearson Education Inc., Upper Saddle River, NJ. All rights reserved. Marilyn Bohl/Maria Rynn Tools for Structured.
Introduction to Flowcharting A Supplement to Starting Out with C++, 4th Edition by Tony Gaddis Published by Addison-Wesley.
Reference :Understanding Computers
CS 1400 Course Reader Introduction. What is Programming? Designing an appropriate algorithm Coding that algorithm in a computer language.
This set of slides is provided by the author of the textbook1 Introductory Topics (Continued) l Computer Components l Basic Control Structures l Problem.
1 9/29/06CS150 Introduction to Computer Science 1 Loops Section Page 255.
CS107 Introduction to Computer Science Loops. Instructions Pseudocode Assign values to variables using basic arithmetic operations x = 3 y = x/10 z =
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
1 9/28/07CS150 Introduction to Computer Science 1 Loops section 5.2, 5.4, 5.7.
CS150 Introduction to Computer Science 1
CS107 Introduction to Computer Science Lecture 2.
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.
CS107 Introduction to Computer Science Lecture 5, 6 An Introduction to Algorithms: List variables.
Designing Algorithms Csci 107 Lecture 3. Administrativia Lab access –Searles 128: daily until 4pm unless class in progress –Searles 117: 6-10pm, Sat-Sun.
Pseudocode.
Lecture Notes 8/30/05 Program Design & Intro to Algorithms.
Pseudocode.
ALGORITHMS AND FLOW CHARTS 1 Adapted from the slides Prepared by Department of Preparatory year Prepared by: lec. Ghader Kurdi.
Algorithm. An algorithm is a procedure for solving a problem in terms of the actions to be executed and the order in which those actions are to be executed.
Algorithm & Flowchart.
Chapter 1 Pseudocode & Flowcharts
Adapted from slides by Marie desJardins
CSC 1051 M.A. Papalaskari, Villanova University Repetition CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing.
An ordered sequence of unambiguous and well-defined instructions that performs some task and halts in finite time Let's examine the four parts of this.
Chapter 5 Repetition or loop structure. What is repetition or loop? repeat the execution of one or a group (block; instruction enclosed in a pair of braces)
© 2011 Pearson Addison-Wesley. All rights reserved. Addison Wesley is an imprint of Stewart Venit ~ Elizabeth Drake Developing a Program.
Practice and Evaluation. Practice Develop a java class called: SumCalculator.java which computes a sum of all integer from 1 to 100 and displays the result.
Introduction to Algorithms. What is Computer Science? Computer Science is the study of computers (??) This leaves aside the theoretical work in CS, which.
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.
Coding Design Tools Rachel Gauci. What are Coding Design Tools? IPO charts (Input Process Output) Input- Make a list of what data is required (this generally.
1 09/20/04CS150 Introduction to Computer Science 1 Let ’ s all Repeat Together.
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.
Coding Design Tools Rachel Gauci. Task: Counting On Create a program that will print out a sequence of numbers from "1" to a "number entered”. Decision’s.
Control Structures CPS120: Introduction to Computer Science Lecture 5.
CS221 Algorithm Basics. What is an algorithm? An algorithm is a list of instructions that transform input information into a desired output. Each instruction.
Basic problem solving CSC 111.
1 Program Planning and Design Important stages before actual program is written.
(C)opyright 2000 Scott/Jones Publishers Introduction to Flowcharting.
CS 240 – Computer Programming I Lab Kalpa Gunaratna –
Sequencing The most simple type of program uses sequencing, a set of instructions carried out one after another. Start End Display “Computer” Display “Science”
Algorithm Discovery and Design Objectives: Interpret pseudocode Write pseudocode, using the three types of operations: * sequential (steps in order written)
8.1 8 Algorithms Foundations of Computer Science  Cengage Learning.
Problem-solving with Computers. 2Outline  Computer System  5 Steps for producing a computer program  Structured program and programming  3 types of.
Flowchart. a diagram of the sequence of movements or actions of people or things involved in a complex system or activity. a graphical representation.
Algorithms and Pseudocode
Controlling Program Structures. Big Picture We are learning how to use structures to control the flow of our programs Last week we looked at If statements.
1 Structured Programming Arab Academy for Science and Technology CC112 Dr. Sherif Mohamed Tawfik The Course.
Selection Using IF THEN ELSE CASE Introducing Loops.
INTRODUCTION TO PROBLEM SOLVING
IGCSE 1 Cambridge Algorithms and flowcharts Unit 7 Computer Science
Chapter 4 C Program Control Part I
PROGRAM CONTROL STRUCTURE
Pseudocode Upsorn Praphamontripong CS 1110 Introduction to Programming
Lecture 2 Introduction to Programming
ALGORITHM Basic CONCEPTS of Basic Concepts of Algorithm
Introduction to pseudocode
Algorithm and Ambiguity
CS150 Introduction to Computer Science 1
Let’s all Repeat Together
Flowcharts and Pseudo Code
Basic Concepts of Algorithm
Repetition CSC 1051 – Data Structures and Algorithms I Course website:
Presentation transcript:

CS 101 – Oct. 7 Solving simple problems: create algorithm Structure of solution –Sequence of steps (1,2,3….) –Sometimes we need to make a choice –Sometimes we need to repeat some steps Examples

Computer science is a problem-solving discipline. Every solution should have a well-defined structure, such as listing the ingredients and steps for input, calculations and output.

Example problems How would you solve these problems? –Print the numbers from 1 to 10. –Searching for something. In this list (3, 2, 7, 5, 4) where is the number 5? Which room contains my umbrella? –Play Tic-Tac-Toe. Idea for solution (algorithm) is more important than typing code at the keyboard.

Computer program Sequence of instructions that machine carries out Nouns and verbs Structure: –Input, calculations, output –Auxiliary functions

Kinds of statements Get input Print output Assign value to variable If-else Loop

Algorithm Clear sequence of steps to arrive at a solution to a problem. Must specify: –Input, output, variables and operations used –The order in which the steps are taken Ideally, each step should perform one calculation: –Input or output of one value –One calculation, or decision to make –Calculations usually limited to basic math –Tedious details can be put off until later.

Examples Algorithm to add two numbers –Ask the user to enter 2 values –Obtain the input, and call the values a and b. –Set a new variable sum and set it to: sum = a + b. –Output sum. Calculate weekly wage. √ –Get hours and rate from the user. –Set the wage as follows: If (hours > 40), use overtime formula Otherwise, use regular formula –Output wage