Algorithms and Flowcharts

Slides:



Advertisements
Similar presentations
Working With Algorithm and Flowcharts
Advertisements

A Level Computing#BristolMet Session Objectives#U2 S2 MUST describe the steps of an algorithm using a program flowchart SHOULD explain the data types and.
PSEUDOCODE & FLOW CHART
Chapter 1 - An Introduction to Computers and Problem Solving
Chapter 2 - Problem Solving
Chapter 2 - Problem Solving
Basics of Computer Programming Web Design Section 8-1.
Chapter 2- Visual Basic Schneider
CIS105 Chapter 1 Theory Review. Page 2 Hardware and Software are the two major components o any computer system Hardware is the set of physical devices.
Chapter 2: Input, Processing, and Output
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 1 Program Design
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Chapter 3 Planning Your Solution
The Program Design Phases
Review Algorithm Analysis Problem Solving Space Complexity
PRE-PROGRAMMING PHASE
Chapter 1 Pseudocode & Flowcharts
CSC103: Introduction to Computer and Programming
DCT 1123 PROBLEM SOLVING & ALGORITHMS INTRODUCTION TO PROGRAMMING.
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.
1. Know the different types of flow block 2. Understand how problems can be broken down into smaller problems.
PROGRAMMING, ALGORITHMS AND FLOWCHARTS
Extended Prelude to Programming Concepts & Design, 3/e by Stewart Venit and Elizabeth Drake Chapter 2: Developing a Program.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
1 Introduction to Flowcharting. 2 Writing a program Defining the problem –Write down what the program will do Planning –Write down the steps, draw a flowchart.
Describe the Program Development Cycle. Program Development Cycle The program development cycle is a series of steps programmers use to build computer.
By the end of this session you should be able to...
Flowcharts and Algorithms. Review of Terms  A computer is a machine that can represent and manipulate data –Ultimately the data and the instructions.
LO: We’re learning to demonstrate the need for breaking down problems into smaller ones.
Program Design BUILDING A HOUSE. Steps to Designing a Program 1. Define the Output 2. Develop the logic to get that output 3. Write the program.
PROGRAM DEVELOPMENT CYCLE. Problem Statement: Problem Statement help diagnose the situation so that your focus is on the problem, helpful tools at this.
1 Program Planning and Design Important stages before actual program is written.
CS 100 Introduction to Computing Seminar September 21, 2015.
Software Development. Software Development Loop Design  Programmers need a solid foundation before they start coding anything  Understand the task.
Slide 1 Controlling Sequences of Events Traffic lights Event table.
Structured Programming (4 Credits)
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Chapter 2 - VB 2005 by Schneider- modified by S. Jane '081 Chapter 2 - Problem Solving 2.1 Program Development Cycle 2.2 Programming Tools.
Algorithms and Pseudocode
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Learning Objective To be able to… Understand flow chart symbols Complete and correct flow chart algorithms Create a program based on a flow chart.
PROBLEM SOLVING. What is a Problem? A problem is a situation that needs to be resolved.
CSE 110: Programming Language I Matin Saad Abdullah UB 404.
 Problem Analysis  Coding  Debugging  Testing.
Chapter 2: Input, Processing, and Output
Chapter Topics 2.1 Designing a Program 2.2 Output, Input, and Variables 2.3 Variable Assignment and Calculations 2.4 Variable Declarations and Data Types.
Unit 2.1 – computational thinking & Algorithms
Print slides for students reference
For -G7 programing language Teacher / Shamsa Hassan Alhassouni.
Programming Fundamentals (750113) Ch1. Problem Solving
Chapter 2- Visual Basic Schneider
Algorithm and Ambiguity
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Software Development Process
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Chapter 2: Input, Processing, and Output
Global Challenge Walking for Water Lesson 2.
Basic Concepts of Algorithm
Global Challenge Walking for Water Lesson 2.
WJEC GCSE Computer Science
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
Global Challenge Walking for Water Lesson 2.
WRITING AN ALGORITHM, PSEUDOCODE, AND FLOWCHART LESSON 2.
Programming Logic and Design Eighth Edition
Introduction to Programming
Presentation transcript:

Algorithms and Flowcharts

Activity 1 What is this an example of and why are they important? It is of course a recipe Important as it allows the same meal to be made, consistently, time and time again. It outlines a set of steps to follow so that anyone can create the same result.

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Hands up if you can explain the following: What is an algorithm?

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Algorithms In general, an 'algorithm' is the name given to a set of steps needed to complete a task. Think of an algorithm as a recipe. For instance you could define an algorithm to make a cup of tea. You start by filling the kettle, then place a tea bag in the cup and so on. In computer terms, an algorithm describes the set of steps needed to carry out a software task or solve a problem

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Algorithms Writing algorithms is all about problem solving. After being given a problem to solve, programmers never begin programming straight away, they will first do the following: Think about the problem Break the problem down into smaller chunks Think of the steps needed to solve each chunk Write down the steps – which in turn becomes the algorithm. This is known as a top down design

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Writing Algorithms Problem Algorithm Algorithms are independent of any language

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Hands up if you can explain the following: What is an algorithm?

Activity 2 In your own words, write down the steps needed to solve the following problem. “Create a program that inputs two numbers, adds them together and then outputs the result onto the screen.”

Activity 2 What did you get? Did you have something like this?… Ask user for a number Store it in variable “number1” Ask user for a second number Store this in variable “number 2” Add the two numbers together Store the result in variable “answer” Display the contents of “answer”.

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Writing Algorithms Writing an algorithm in a specific language: Too time consuming Pointless – could just code Can’t be taken by a programmer using a different language Too complex – need knowledge of syntax (code specific to a language) Writing an algorithm in everyday language: Too time consuming Inaccurate as it could be open to interpretation Algorithms are independent of any language There are therefore methods used to write algorithms so that they are succinct, accurate and easy to understand so that a programmer of any language could understand the steps required to solve a task: Flowcharts and Pseudocode

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Writing Algorithms Problem: Calculate the Sales Tax (VAT) of an item and then using it to work out the final price 1. Flowchart 2. Pseudocode Examples of each method of algorithm writing

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Flowcharts Today we will focus on Flowcharts Visual representation of a system Small number of symbols used to represent individual steps Arrows show the flow of control within the algorithm (the order of instructions) Easier to trace a sequence of steps and locate errors than in pseudocode. Start Is temp < 19 Is temp > 21 Turn heating on Turn heating off Yes No Example: A central heating system will try to keep the temperature between 2 values (19 and 21) If the temperature falls below 19 It will turn the heating system on If the temperature rises above 21 it will switch the heating system off.

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Start and Stop Symbols All flow charts begin with a Start Symbol and at the end of the flow chart (or at various end points of the chart) we place a Stop Symbol. There are drawn as a rectangle with curved ends Flowcharts and their symbols Start Stop

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Process Symbols Most of the time a flow chart will demonstrate the sequence of instructions to be carried out. Simple processes (like “Add 1 to x” or “append x to List”) are shown using a standard rectangle. Flowcharts and their symbols Add 1 to x Append x to “List”

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Input / Output Symbols At times your program will most certainly ask the user for inputs and output values too. Inputs and Outputs (like “Name?” or “…display age”) are shown using a parallelogram. Name? Flowcharts and their symbols Store in variable “Name” Display Name

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Decision Symbols At times your program will be programmed to make a decision based on certain conditions. Decisions (like “IF X = 3” or “While Y > 3”) are shown using a diamond. Flowcharts and their symbols If X = 3 Yes Display “X equals 3” No Display “X doesn’t equal 3”

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Flowcharts and their symbols

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Flowcharts and their symbols

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. 4 things you need to be able to do with algorithms for your exam Understand them Correct them if they have errors, Complete them if they are incomplete Produce them after being given a problem to solve

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Tips on reading algorithms. Start from top and follow the arrows Remember what the symbols mean Read each symbol description Logically work out what the algorithms is doing. Task: What is this algorithm doing?

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Tips on correcting algorithms. Start Is temp > 19 Is temp < 21 Turn heating on Turn heating off Yes No Read the flowchart and look for decisions which don’t make sense Start X = 10 while X < 10 Yes X = X + 1 Or it might be a loop which you cannot get into or perhaps out of. No End

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Tips on completing algorithms. Start from top and follow the arrows Remember what the symbols mean Read each symbol description Logically work out what the algorithms is doing. THEN, Use your knowledge of the algorithm so far AND Use your knowledge of the follow chart symbols …and complete the flowchart

Algorithms and Flowcharts Learning Objectives: (a) understand algorithms (written in pseudocode or flow diagram), explain what they do, and correct or complete them (b) produce algorithms in pseudocode or flow diagrams to solve problems. Tips on writing algorithms.

Activity 3 Make notes explaining what an algorithm is, what a flowchart is and the flowchart symbols for: start / stop input / output processes Decisions