Computational thinking Worksheet 3, Exercises of Computer science

Computer Science is the study of computers and computational systems. It involves understanding the theory, design, development, and application of software and hardware to solve problems efficiently. This field covers areas such as algorithms, programming languages, data structures, artificial intelligence, computer networks, cybersecurity, and software engineering. Computer science plays a crucial role in advancing technology and impacting various industries through innovation and automation.

Typology: Exercises

2023/2024

Uploaded on 06/11/2025

wdcv-sdcsdv
wdcv-sdcsdv 🇬🇧

4 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Worksheet 3: Thinking procedurally
Unit 10 Computational thinking
Worksheet 3 Thinking procedurally
1. You have been asked to write a procedure to count the number of vowels in a sentence.
How can you ensure that the procedure will work for any length of sentence?
2. To implement a stack, you would need three procedures: InitialiseStack(stack),
AddToStack(stack, item), RemoveFromStack(stack).
The identifiers in brackets are parameters defined in the main program and passed to the
procedure.
What procedures and parameters would you need to be able to implement a queue?
3. A hierarchy chart can be compared to an upside-down tree, with the root at the top and
branches and leaves spreading downwards.
The “leaves” are the lowest level modules and all or most of the detailed program code will
be in the “leaves”.
In the hierarchy chart below:
(a) Which are the Level 1 modules?
(b) Which are the Level 2 modules?
(c) Which are the Level 3 modules?
(d) Write down the order in which the modules are executed.
1
5
10
11
8
9
7
4
2
3
1
6
pf3
pf4

Partial preview of the text

Download Computational thinking Worksheet 3 and more Exercises Computer science in PDF only on Docsity!

Unit 10 Computational thinking

Worksheet 3 Thinking procedurally

1. You have been asked to write a procedure to count the number of vowels in a sentence.

How can you ensure that the procedure will work for any length of sentence?

2. To implement a stack, you would need three procedures: InitialiseStack(stack),

AddToStack(stack, item), RemoveFromStack(stack).

The identifiers in brackets are parameters defined in the main program and passed to the

procedure.

What procedures and parameters would you need to be able to implement a queue?

3. A hierarchy chart can be compared to an upside-down tree, with the root at the top and

branches and leaves spreading downwards.

The “leaves” are the lowest level modules and all or most of the detailed program code will

be in the “leaves”.

In the hierarchy chart below:

(a) Which are the Level 1 modules?

(b) Which are the Level 2 modules?

(c) Which are the Level 3 modules?

(d) Write down the order in which the modules are executed.

Unit 10 Computational thinking

4. What are the advantages of structured programming?

5. The following pseudocode program is designed to allow the user to input a series of three

numbers and for each set of numbers, find and output the maximum. The maximum is then

added to a total. When the user enters 0 for each of the three numbers, the average of all

the maximums is calculated and output.

SUB initialise OUTPUT “This program finds the maximums of sets of three numbers. Enter three zeroes when all numbers entered. Program then calculates and outputs the average of the maximums” total = 0 n = 0 ENDSUB SUB promptForNumbers OUTPUT"Please enter first number " num1 = USERINPUT OUTPUT ("Please enter second number " num2 = USERINPUT OUTPUT "Please enter third number " num3 = USERINPUT ENDSUB SUB findMax maxnum = num IF num2>maxnum THEN maxnum = num ELSE IF num3>maxnum THEN maxnum = num ENDIF OUTPUT "Max of the three numbers is is ",maxnum ENDSUB SUB performCalculations total = total + maxnum n=n+ ENDSUB SUB processData promptForNumbers WHILE num1<>0 and num2<>0 and num3<> findMax performCalculations promptForNumbers ENDWHILE ENDSUB SUB calculateAverage average = total/n OUTPUT "Average of maximums is ",average

Unit 10 Computational thinking

ENDSUB

#Main program starts here initialise processData calculateAverage

Draw a hierarchy chart representing this program. Show the different levels, i.e. Level 1

modules, Level 2 modules etc.