KS3 Computing/Algorithms Using Sequencing

From Wikibooks, open books for an open world
Jump to navigation Jump to search


Recipes are frequently used as an example of algorithms in everyday life. The ingredients can be compared to the data and the method to the instructions which make up the algorithms.

Algorithm (MEMORISE) - An algorithm is a _________________________ (or _________________________ or _______________________ ) of _________________________ to solve a specific problem.

Flowcharts and Pseudo-Code are both used to describe algorithms. A flowchart represents an algorithm in a visual way. Pseudo code is used to describe an algorithm in a human language, like English.

An algorithm describes the path or flow of execution of a program with the help of a flowchart or pseudo code. In other words: flowcharts and pseudocode allow us to describe the order in which the instructions need to be completed, so that the problem con be solved.

Algorithms using Sequencing Exercises

[edit | edit source]

In the previous chapter, you learnt that the manipulation of data can produce solutions. Computer Scientists refer to this as changing the state of a program.

Worked Example

[edit | edit source]

Only the most simple problems can be solved using algorithms which only use sequencing. For example a simple two-number adder, which has two numbers as input, processes these numbers by adding them together to present this as the output. Programmers would not produce a structure diagram, variable dictionary, pseudo code and flow chart. However, for the purpose of this guide I will use this very simple example to illustrate all of the processes necessary to program a solution.

1 - De-composition:

Sub-problem 1: getting the input into the system

Sub-problem 2: adding the two numbers together

Sub-problem 3: presenting the result as output

The Structure Diagram:


2 & 3 - Data Requirements and Variables variable (data) dictionary: number1, type float number2, type float number3, type float

4 - Algorithm The Pseudo-Code get the first number and store as number1 get second number and store as number2 calculate sum and store as number3 present number3 The Flowchart:


Attempt to solve the following problems using the same method.

Exercise 1

[edit | edit source]

Calculate the circumference of a circle, according to a given radius.

Exercise 2

[edit | edit source]

Calculate the volume of a cube, given the length of the faces.

Exercise 3

[edit | edit source]

Allow a user to enter his or her first name and his or her surname. Print a greeting for the user which included both names.

Exercise 4

[edit | edit source]

Allow a user to enter the year in which he or she is born. Respond with a greeting which includes the age of the user. Exercise 5 Allow a user to enter his or her name and age. Print a response which tells the user what age he or she will be in the year 2066.�

Algorithms using Sequencing Summary

[edit | edit source]

Algorithms are likely to make use of sequencing In a sequence, one instruction is followed by another. A sequence describes the path or flow of execution.

Algorithms using Sequencing Further Study

[edit | edit source]

Visit the website of ‘Computer Science for Fun’ and read the articles under the section for algorithms and computational thinking.�