Presentation is loading. Please wait.

Presentation is loading. Please wait.

WJEC GCSE Computer Science

Similar presentations


Presentation on theme: "WJEC GCSE Computer Science"— Presentation transcript:

1 WJEC GCSE Computer Science
Unit 1 Algorithms

2 Objectives To demonstrate an understanding of algorithms by:
Interpreting Algorithms and “Dry Running” simple algorithms Describing the different Data Structures required in an algorithm Use Pseudocode and Flow charts to represent solutions to problems Complete, Test, and Correct algorithms

3 Algorithms Computer programs are usually written to solve a problem and an algorithm is a set of step-by-step rules, written for a computer, that explain how the problem is to be solved. There are two methods that are commonly used to describe algorithms – pseudo code and flowcharts.

4 Pseudo Code Pseudo code looks like a programming language, but it isn't. It's a cross between English and a generic-looking programming language. It is useful for some, because it is a halfway point between describing the program in English and having a complete program written in a language such as Visual Basic, Java or Python.

5 Pseudo Code A pseudo code algorithm for calculating the cost of a purchase at a till might be as follows: INPUT price INPUT quantity total = price * quantity OUTPUT total

6 Pseudocode: Component 2 Skills
In your component 2 exam you need to be able to: Calculate the total Input data using the right data type e.g. Total = Total + Number Output “Enter a score” Input Score as Integer Calculate the Average Average = Total / HowMany Repeat an instruction a user inputted amount of times: Output Messages before an input Output “How many things are there?” Input HowMany as integer For i 1 to HowMany: Indent the repeated code! Output the information at the end of the algorithm Calculate the Maximum Output “Input number” Output “The total is” + Total Input number as integer Output “The maximum is” + Maximum If number > Maximum: Output “The minimum is” + Minimum Maximum = number Output “The Average is” + Average Calculate the Minimum If number > Minimum: Minimum = number

7 Flowcharts A flowchart does the same job as pseudo code in defining an algorithm, but it is a diagrammatical representation.

8 Flowcharts A flowchart does the same job as pseudo code in defining an algorithm, but it is a diagrammatical representation.

9 Workbook Complete section 6 Q1

10 Sequence Sequence is when instructions in an algorithm each need to be executed only once, and in the order in which they are written.

11 Selection Selection is when one sequence of instructions or another, but not both, is executed. The sequence that is executed will depend on what happened in earlier instructions. The following example either adds £10 or £5, depending on whether an adult or a child is paying to get into an attraction. Words such as IF mean that selection is taking place.

12 Selection The diamond shape is a decision box, which asks a question (the answers being written along the arrows), determining which path the program should take next.

13 Iteration Iteration takes place when one or more instructions is executed more than once. Iteration is also known as repetition. Iteration is taking place when the program code (or pseudo code) contains the words LOOP, FOR, WHILE or REPEAT. The following algorithm might be used in an online system for ordering pizza:

14 Iteration

15 Workbook Complete section 6 Q2-6


Download ppt "WJEC GCSE Computer Science"

Similar presentations


Ads by Google