100% found this document useful (1 vote)
887 views

WB Chapter 7 Algorithm Design and Problem Solving

The document discusses various aspects of the program development lifecycle including its stages, tools used at each stage, and methods for designing problem solutions. It asks the reader to identify the stages of the lifecycle, describe how abstraction, decomposition, and structure diagrams are used and at what stage, list components of a computer system, and describe three methods for designing problem solutions.

Uploaded by

Riaz Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
887 views

WB Chapter 7 Algorithm Design and Problem Solving

The document discusses various aspects of the program development lifecycle including its stages, tools used at each stage, and methods for designing problem solutions. It asks the reader to identify the stages of the lifecycle, describe how abstraction, decomposition, and structure diagrams are used and at what stage, list components of a computer system, and describe three methods for designing problem solutions.

Uploaded by

Riaz Khan
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 21

Algorithm design and

7 problem solving
1 Identify and describe three stages of the program development lifecycle.

1  
............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

2  
............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

3  
............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

2 Abstraction, decomposition and structure diagrams are tools used during the program development
lifecycle. Identify the stage of the program development lifecycle where they are used and
describe what they are used for.

Abstraction

Stage: ...............................................................................................................................................................

Use: ....................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

Decomposition

Stage: ................................................................................................................................................................

Use: ....................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................
Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
5

318472_07_IGCSE_OLCSPW_005-025.indd 5 24/04/21 1:27 PM


7 Algorithm design and problem solving

Structure diagram

Stage: ................................................................................................................................................................

Use: ....................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

3 a Identify three of the different items, other than software, that make up a computer system.

1  
.......................................................................................................................................................................

2  
.......................................................................................................................................................................

3  
.......................................................................................................................................................................

b State three of the component parts of a computer system.

1  
.......................................................................................................................................................................

2  
.......................................................................................................................................................................

3  
.......................................................................................................................................................................

4 Identify and describe the three methods you could use to design and construct a solution
to a problem.

1  
............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

2  
............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

3  
............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

............................................................................................................................................................................

Photocopying prohibited
6 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 6 24/04/21 1:27 PM


7 Algorithm design and problem solving

5 Use the following list of words and phrases to complete the paragraph below.

Each word or phrase can be used once, more than once or not at all.
» breakdown » description » hierarchical » top-down
» bottom-up » diagrammatic » level » structure diagram
» composition » flowchart » program » system
» decomposition » formal » pseudocode » sub-systems

Structure diagrams are used to show the .................................... design of a computer ....................................

in a .................................... form.

A structure diagram shows the design of a computer program in a .................................... way

with each .................................... giving a more detailed .................................... of the ....................................

into .....................................

6 a Draw and describe the use of four flowchart symbols.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................
Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
7

318472_07_IGCSE_OLCSPW_005-025.indd 7 24/04/21 1:27 PM


7 Algorithm design and problem solving

.............................................................................................................................................................................

.............................................................................................................................................................................

b Describe the purpose of flow lines in a flowchart.

.............................................................................................................................................................................

.............................................................................................................................................................................

7 Describe the function of each of the following types of pseudocode statement and give an example
in pseudocode of the use of each one.

Assignment:

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

Conditional:

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

Photocopying prohibited
8 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 8 24/04/21 1:27 PM


7 Algorithm design and problem solving

Iterative:

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

..................................................................................................................................................................................

8 a There are three different types of loop structure in pseudocode.

For each one, describe the structure and write the pseudocode statements needed
to output the names of 20 students that have been stored in the array
Student[0:19]. Use the variable Counter for the iteration.

Loop 1: ..............................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

Loop 2: ..............................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
9

318472_07_IGCSE_OLCSPW_005-025.indd 9 24/04/21 1:27 PM


7 Algorithm design and problem solving

Loop 3: ..............................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

b i There are two different types of conditional statements used in pseudocode.

For each one, write the pseudocode statements needed to output a different welcome
message for each name input from 'Alice', 'Abid', 'Dinesh', 'Daisy' or 'Zak' or a rejection
message. Use the variable Name for the input.

Conditional Statements 1: ........................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................

Photocopying prohibited
10 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 10 24/04/21 1:27 PM


7 Algorithm design and problem solving


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................

Conditional Statements 2: .......................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................


.......................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
11

318472_07_IGCSE_OLCSPW_005-025.indd 11 24/04/21 1:27 PM


7 Algorithm design and problem solving

ii State, with reasons, which conditional statement is more appropriate to use in this case.

.......................................................................................................................................................................

.......................................................................................................................................................................

.......................................................................................................................................................................

c There are two different ways of writing a flowchart to output the names of twenty students
that have been stored in the array Student[0:19]. The loop counter Counter is tested at
the start of the loop (pre-condition) or at the end of the loop (post-condition).

i Draw flowcharts for the pre-condition loop and the post-condition loop.

Pre-condition loop:

Post-condition loop:

Photocopying prohibited
12 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 12 24/04/21 1:27 PM


7 Algorithm design and problem solving

ii Identify which pseudocode loop statements matches each flowchart.

.......................................................................................................................................................................

.......................................................................................................................................................................

.......................................................................................................................................................................

.......................................................................................................................................................................

d When you have learnt how to write programs that include loops, write three programs to test
that your answers to part a work as intended.
Hint: for Python there will only be two programs.

Loop 1: ..............................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

Loop 2: ..............................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

Loop 3: ..............................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................


............................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
13

318472_07_IGCSE_OLCSPW_005-025.indd 13 24/04/21 1:27 PM


7 Algorithm design and problem solving

9 a Write an algorithm in pseudocode to input ten numbers and output the total.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

b Write an algorithm using a flowchart to input ten numbers and output the total.

Photocopying prohibited
14 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 14 24/04/21 1:27 PM


7 Algorithm design and problem solving

10 Look at this algorithm, shown as a flowchart:

START

OUTPUT 'How many


guesses would
you like?'

INPUT N

OUTPUT 'Please
enter your
guess:'

INPUT G

yes OUTPUT 'Well


G = W? done you guessed
the word'

no

N ← N - 1

no N = 0?

yes

OUTPUT 'You
failed to guess
the word'

STOP

a Identify the processes in the algorithm.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
15

318472_07_IGCSE_OLCSPW_005-025.indd 15 24/04/21 1:27 PM


7 Algorithm design and problem solving

b Describe the purpose of the algorithm.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

c Rewrite the algorithm in pseudocode.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

Photocopying prohibited
16 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 16 24/04/21 1:27 PM


7 Algorithm design and problem solving

11 Use the following list of words and phrases to complete the paragraph below.

Each word or phrase can be used once, more than once or not at all.
» algorithms » maximum
» average » mode
» bubble » minimum
» counter » search
» counting » sort
» linear » testing
» list » totalling

Standard methods of solution are used in the design of .............................................. . These include

adding in a new value every time an action occurs, for example, awarding a mark to each

student – this is called .............................................. . When divided by the number of times this

occurs, this gives the .............................................. . Keeping a record of the number of times an

action occurs is called .............................................. . Finding the largest, .............................................. ,

and smallest, .............................................. , are also standard methods.

In order to look for an item in a list a .............................................. is used. The method you need to

know for IGCSE Computer Science is to inspect each item in the .............................................. in turn to

see if it is the one required. This is called a .............................................. .............................................. .

To put a list in order a .............................................. is used. The method you need to know for IGCSE

Computer Science is called a .............................................. .............................................. .

12 a Explain the operation of a bubble sort.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
17

318472_07_IGCSE_OLCSPW_005-025.indd 17 24/04/21 1:27 PM


7 Algorithm design and problem solving

b Write a bubble sort algorithm in pseudocode to sort a list of ten names, in an array called
Names[], in ascending order.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

13 Validation and verification checks are used on values that are input into a computer program.

a i State when it is appropriate to use validation.

.......................................................................................................................................................................

.......................................................................................................................................................................

ii State when it is appropriate to use verification.

.......................................................................................................................................................................

.......................................................................................................................................................................

b i Give two examples of validation checks.

1  
.................................................................................................................................................................

2  
.................................................................................................................................................................

ii Give two examples of verification checks.

1  
.................................................................................................................................................................

2  
.................................................................................................................................................................

Photocopying prohibited
18 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 18 24/04/21 1:27 PM


7 Algorithm design and problem solving

14 a Explain the purpose of test data.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

b i Boundary data is one type of test data. Identify and describe three other types of
test data.

1  
.................................................................................................................................................................

.................................................................................................................................................................

.................................................................................................................................................................

.................................................................................................................................................................

2  
.................................................................................................................................................................

.................................................................................................................................................................

.................................................................................................................................................................

.................................................................................................................................................................

3  
.................................................................................................................................................................

.................................................................................................................................................................

.................................................................................................................................................................

.................................................................................................................................................................

ii Give the set of boundary data needed to check that a whole number is less than 100.

1  
.................................................................................................................................................................

2  
.................................................................................................................................................................

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
19

318472_07_IGCSE_OLCSPW_005-025.indd 19 24/04/21 1:27 PM


7 Algorithm design and problem solving

15 a Use the trace table and the test data 78, 34, 22, −4, 98, 16, 734, 88, 999 to record a
dry run of this algorithm written in pseudocode.
W ← 0
X ← 0
Y ← 100
Z ← 0
REPEAT
INPUT Mark
IF Mark <> 999
THEN
REPEAT
IF Mark < 0 OR Mark > 100
THEN
INPUT Mark
ENDIF
UNTIL Mark >= 0 AND Mark <= 100
IF Mark > X
THEN
X ← Mark
ENDIF
IF Mark < Y
THEN
Y ← Mark
ENDIF
Z ← Z + Mark
W ← W + 1
ENDIF
UNTIL Mark = 999
OUTPUT X, Y, Z

W X Y Z Mark OUTPUT

Photocopying prohibited
20 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 20 24/04/21 1:27 PM


7 Algorithm design and problem solving

b State the purpose of the algorithm.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

c Rewrite the algorithm as a flowchart.

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
21

318472_07_IGCSE_OLCSPW_005-025.indd 21 24/04/21 1:27 PM


7 Algorithm design and problem solving

d Use the guidance in Chapter 8 to rewrite this algorithm in pseudocode, ensuring that:
» there are meaningful prompts and outputs
» the algorithm could be read and understood by someone else.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

22 Photocopying prohibited Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 22 4/29/21 12:17 PM


7 Algorithm design and problem solving

e Devise another set of test data that includes normal, erroneous and extreme data and complete
a trace table to perform a dry run on your algorithm.

Test data: .........................................................................................................................................................


............................................................................................................................................................................

Trace table:

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
23

318472_07_IGCSE_OLCSPW_005-025.indd 23 24/04/21 1:27 PM


7 Algorithm design and problem solving

16 The following flowchart shows an algorithm that checks a temperature input is between 20 and
30 degrees. It contains several errors.
START

INPUT 'Please
enter the
temperature'

OUTPUT T

T < 30? yes


OUTPUT 'Too Low'

no

T > 20? OUTPUT 'Too High'

OUTPUT 'In Range'

STOP

a Identify the errors in the algorithm and the flowchart construction.

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

.............................................................................................................................................................................

Photocopying prohibited
24 Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook

318472_07_IGCSE_OLCSPW_005-025.indd 24 24/04/21 1:27 PM


7 Algorithm design and problem solving

b Draw the corrected flowchart.

Photocopying prohibited
Cambridge IGCSE and O Level Computer Science Algorithms, Programming and Logic Workbook
25

318472_07_IGCSE_OLCSPW_005-025.indd 25 24/04/21 1:27 PM

You might also like