[go: up one dir, main page]

0% found this document useful (0 votes)
8 views9 pages

9.1_9.2 Algorithm Design 2024_copy

The document discusses computational thinking and its techniques, including abstraction, decomposition, algorithms, and pattern recognition, which are essential for problem-solving in computer science. It explains how abstraction simplifies complex problems, decomposition breaks them into manageable parts, and the use of algorithms to outline solutions in structured English, pseudocode, and flowcharts. Additionally, it covers the constructs used in algorithms such as assignment, sequence, selection, and iteration, along with examples of writing pseudocode and flowcharts.

Uploaded by

avinashnapaul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views9 pages

9.1_9.2 Algorithm Design 2024_copy

The document discusses computational thinking and its techniques, including abstraction, decomposition, algorithms, and pattern recognition, which are essential for problem-solving in computer science. It explains how abstraction simplifies complex problems, decomposition breaks them into manageable parts, and the use of algorithms to outline solutions in structured English, pseudocode, and flowcharts. Additionally, it covers the constructs used in algorithms such as assignment, sequence, selection, and iteration, along with examples of writing pseudocode and flowcharts.

Uploaded by

avinashnapaul
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 9

A Level Computer Science P2 N.

Algorithm Design & Problem Solving


Computational thinking skills

Computational thinking is used to study a problem and formulate an effective solution that can
be provided using a computer.

There are several techniques used in computational thinking, including abstraction,


decomposition, algorithms and pattern recognition.

Abstraction – the process of extracting information that is essential, while ignoring what is not
relevant, for the provision of a solution.

Many everyday items use abstraction, such as maps, calendars and timetables.

For example, a road map should only show the necessary detail required to drive from one place

in
to another. The road map may reduce the complexity by only showing the essential details
needed, such as roads, road numbers and towns, and removing other information about the
terrain that would not be helpful.

st
The benefits of eliminating any unnecessary characteristics from the model include:

• the time required to develop the program is reduced so the program can be delivered to
the customer more quickly.
u
• the program is smaller in size so takes up less space in memory and download times are
shortened.
g
• customer satisfaction is greater as their requirements are met without any extraneous
features.
u

Decomposition – the process of breaking a complex problem into smaller parts.


A
r.
M

Decomposition leads us to the concept of program modules and using procedures and
functions.

1
A Level Computer Science P2 N.A

Data modelling involves analysing and organising data.

We can set up abstract data types to model real-world concepts, such as queues or stacks.
When a programming language does not have such data types built-in, we can define our own
by building them from existing data types. There are more ways to build data models:

• object-oriented programming where we build data models by defining classes.


• using facts and rules.
• using random files.

Pattern recognition – the identification of parts of a problem that are similar and could use the
same solution.

There are many standard algorithms to solve standard problems, such as sorting or searching.

in
Algorithms
Algorithm – an ordered set of steps to be followed in the completion of a task.

st
When we design a solution to a problem we express the solution (the algorithm) using
sequences of steps written in structured English, pseudocode and flowchart.
u
Structured English – a method of showing the logical steps in an algorithm, using an agreed
subset of straightforward English words for commands and mathematical operations.
g
Pseudocode – a method of showing the detailed logical steps in an algorithm, using keywords,
identifiers with meaningful names, and mathematical operators.
u

Flowchart – a diagrammatic representation of an algorithm.


A
r.
M

2
A Level Computer Science P2 N.A

in
st
u
g
u
A
r.

When writing algorithms, we use four basic types of construct:

• Assignment: a value is given a name (identifier) or the value associated with a given
identifier is changed.
M

• Sequence: a number of steps are performed, one after the other.


• Selection: under certain conditions some steps are performed, otherwise different (or
no) steps are performed.
• Repetition: a sequence of steps is performed a number of times. This is also known as
iteration or looping.

3
A Level Computer Science P2 N.A

To input a value:

To output a message or a value or a combination:

To assign a value to a variable (the value can be the result of a process or a calculation):

in
st
u
g
Operators used in pseudocode assignment statements:
u
A
r.
M

To perform a selection using IF statements for a single choice or a choice and an alternative,
and CASE statements when there are multiple choices or multiple choices and an alternative:

4
A Level Computer Science P2 N.A

Relational operators used in pseudocode selection statements:

in
st
u
To perform iteration using FOR, REPEAT–UNTIL and WHILE loops:
g
u
A

A FOR loop has a fixed number of repeats, the


r.

STEP increment is an optional expression


that must be a whole number.
M

➢ Statements in a REPEAT loop are always executed at least once.

5
A Level Computer Science P2 N.A

➢ Statements in a WHILE loop may sometimes not be executed.

WHILE and REPEAT loops and IF statements make use of comparisons to decide whether
statements within a loop are repeated or a statement or group of statements are executed.

The comparisons make use of relational operators and the logic operators AND, OR and NOT.

in
The outcome of these comparisons is always either true or false.

st
u
Writing pseudocode from a structured English description
g
From a structured English description, the following things need to be possible:
u

• Any variables that need to be used can be identified and put in an identifier table – these
can be items input or output as the results of calculations.
• Input and output can be identified from the wording used, for example,
A

• Enter, Read, Print, Write.


• Selection can be identified from the wording used, for example, If, Then, Choose.
• Any iteration required can be identified from the wording used, for example, Loop,
r.

Repeat.
• Any processes needed can be identified from the wording used, for example, Set,
Calculate.
M

Here is an example of an algorithm to calculate a runner’s marathon time in seconds, using


structured English.

6
A Level Computer Science P2 N.A

This can be used to identify the variables required and complete the identifier table:

It is good practice to keep track of any identifiers used in an identifier table.

Using these identifiers, each step of the structured English algorithm can be converted to
pseudocode, as demonstrated below.

in
st
u
g
u
A
r.
M

7
A Level Computer Science P2 N.A

Writing pseudocode from a flowchart

in
st
u
Here is an example of a flowchart of an algorithm that can be used to check an exam grade:
g
u
A
r.
M

8
A Level Computer Science P2 N.A

The same algorithm is presented in the pseudocode below:

in
st
u
g
Stepwise refinement – the practice of subdividing each part of a larger problem into a series of
smaller parts, and so on, as required.
u

Look at the first step of the structured English to calculate a time in seconds.
A

The first step can be further broken down, as follows:


r.
M

Each of these steps can be broken down further:

You might also like