9 Algorithm Design and Problem solving
Show an understanding of abstraction, including the need for and benefits of using abstraction,
and the purpose of abstraction, and produce an abstract model of a system by only including
essential details
Abstraction involves extracting information that is essential while ignore what is not relevant for the
provision (hide unwanted details), we need abstraction to develop simplified models, hide
complexity
Benefits
- time required to develop the program is reduced so the program can be delivered to the
customer quickly
- program is smaller in size so takes up less space in memory and download times are
shortened
- customer satisfaction is greater as their requirements are met without any extraneous
feature
Describe and use decomposition, by breaking down problems into sub-problems leading to the
concept of a program module(procedure/function)
Decomposition allows computer scientists to break a complex problem into smaller parts that can be
further subdivided into even smaller parts until each part is easy to examine and understand, and
solution can be developed for it for modular programming
Why – program code is easier to implement and test/debug, module maybe given to different
people to develop, Encourages the re-usability of program code
Show understanding that algorithm is a solution to a problem expressed as a sequence of
defined steps
Algorithm is an ordered set of steps to be followed in the completion of a task
Use suitable identifier names for the representation of data used by a problem and represent
these using an identifier table
,Write pseudocode that contains input, process and output
INPUT Answer
OUTPUT Score
OUTPUT "You have ", Lives, " lives left"
+, -, *, /, &, ←, <>(not equal), MOD(remainder), DIV(return integer only
(2.9 → 2))
Write pseudocode using the three basic constructs of sequence, selection, and iteration
(repetition)
Sequence -- Instructions / lines of code are executed in a fixed order
IF MyValue > YourValue
THEN
OUTPUT “I win”
ELSE
OUTPUT “You win”
END IF
INPUT Move
CASE OF Move
ꞌWꞌ : Position ← Position − 10
ꞌSꞌ : Position ← Position + 10
ꞌAꞌ : Position ← Position − 1
ꞌDꞌ : Position ← Position + 1
OTHERWISE : OUTPUT “Error”
ENDCASE
Count controlled for loop
Total ← 0
FOR Counter ← 1 TO 10
OUTPUT “Enter number”
INPUT Number
Total ← Total + number
NEXT Counter
Post condition repeat loop
REPEAT
OUTPUT "Please enter the password"
INPUT Password
UNTIL Password = "Secret" #always executed at least once
Pre-condition while loop
INPUT Number
WHILE Number > 9
Number ← Number – 9
ENDWHILE
, Document a simple algorithm using pseudocode
Write pseudocode from a structured English description and a flow chart
Structure English is a method of showing logical steps in an algorithm, using straightforward English
words for commands and mathematical operations to represent the solution. Steps are numbered.
When writing structured English, consider the following:
- identified the variables used and put them into identifier table
- I/O use enter, read, write, print
- Selection use If, then, choose,
- Iteration use loop, repeat
- Process use Set, Calculate
Flowchart shows as a diagram, symbols are linked together with flow lines, showing how a task is
performed, showing the structure of an algorithm.
Flow chart:
Describe and use the process of stepwise refinement to express an algorithm to a level of detail
from which the task might be programmed
Series of steps where each step can be written as a statement in a high-level programming language,
by increasing the level of detail, and break down a task into smaller points
Use logical statement to define parts of an algorithm solution
Logical statement includes (if (A AND B) OR (C AND D))