Download presentation
1
Algorithms and Flowcharts
2
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.
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. Hands up if you can explain the following: What is an algorithm?
4
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
5
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
6
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
7
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?
8
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.”
9
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”.
10
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
11
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
12
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.
13
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
14
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”
15
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
16
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”
17
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
18
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
19
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
20
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?
21
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
22
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
23
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.
24
Activity 3 Make notes explaining what an algorithm is, what a flowchart is and the flowchart symbols for: start / stop input / output processes Decisions
Similar presentations
© 2025 SlidePlayer.com Inc.
All rights reserved.