Professional Documents
Culture Documents
Show understanding that every computer system is made up of sub-systems, which in turn are
made up of further sub-systems
A subsystem is a set of elements, which is a system itself, and a component of a larger system.
R
Components and subsystems fall into three categories: hardware, software, and network.
KU
Elements of a system: an example
Following are considered as the elements of a system in terms of Information systems:
Input
Output
Processor
Control
Feedback
A
Boundary and interface
Environment
Types of systems
Systems are classified in different ways:
Physical or abstract systems.
TH
Open or closed systems.
'Man-made' information systems.
Formal information systems.
Informal information systems.
Computer-based information systems.
Real-time system.
ED
Use top-down design, structure diagrams, flowcharts, pseudocode, library routines and
subroutines
In order to understand how a computer system is built up and how it works, it is often divided up into
sub-systems. This division can be shown using top-down design to produce structure diagrams that
HM
demonstrate the modular construction of the system. Each sub-system can be developed by a
programmer as sub-routine or an existing library routine may be already available for use. How each
sub-routine works can be shown by using flowcharts or pseudocode.
Subroutines
Top-down design
A technique in which program/algorithm broken down into simpler modules/smaller tasks where
each module is further sub-divided until basic elements are produced. It allows several programmers
to work at same time on the software. Programmers can test each module independently.
OR
Top down design also called stepwise refinement is breaking down the problem/task/program into
sub problems/smaller tasks/modules.
Advantages
Breaking the problem into parts helps us to clarify what needs to be done.
At each step of refinement, the new parts become less complicated and, therefore, easier to
figure out.
Parts of the solution may turn out to be reusable.
R
Breaking the problem into parts allows more than one person to work on the solution
Disadvantages
KU
It is difficult to guarantee that the initial design adequately models the desired system
It is tougher to do testing, as a large portion of the design must be done first
On a large projects, redundant code may become an issue
Structure Diagram
Data structure diagram (DSD) is a diagram of the conceptual data model which documents the
A
entities and their relationships, as well as the constraints that connect to them.
Structure Chart
A Structure Chart (SC) in software engineering and organizational theory, is a chart which shows the
breakdown of a system to its lowest manageable levels. They are used in structured programming
TH
to arrange program modules into a tree. Each module is represented by a box, which contains the
module's name. The tree structure visualizes the relationships between modules.
Customers place their orders for any number of items to a given store.
Structure Diagram:
HM
A
R
KU
A
TH
Structure diagram for Alarm App
R
KU
A
TH
ED
HM
Algorithm
What is an algorithm?
An algorithm is a precise, step-by-step set of instructions for solving a task. An algorithm does not
solve a task; it gives you a series of steps that, if executed correctly, will result in a solution to a
task.
R
What is algorithmic thinking?
Algorithmic thinking is the ability to understand, execute, evaluate, and create algorithms. Let's
discuss each of these ideas separately.
KU
Algorithm is written in two ways:
Pseudocode
Flowchart
A
REPEAT
Wait 10 seconds
Get Time
UNTIL Time = Alarm Time
Sound Alarm
TH
Flowchart
A FLOWCHART shows diagrammatically the steps required for a task (sub-system) and the order that
they are to be performed. These steps together with the order are called an ALGORITHM. Flowcharts
are an effective way to communicate the algorithm that shows how a system or sub-system works.
ED
Library routines
A LIBRARY ROUTINE is a set of programming instructions for a given task that is already available for
use. It is pre-tested and usually performs a task that is frequently required. For example, the task ‘get
time’ in the checking-for-the-alarmtime algorithm would probably be readily available as a library
routine.
Sub-routines
A SUB-ROUTINE is a set of programming instructions for a given task that forms a subsystem, not the
whole system. Sub-routines written in high-level programming languages are called ‘procedures’ or
R
‘functions’ depending on how they are used. See Chapter 11 for further details.
KU
A
TH
ED
HM
A
Example: Pseudocode
SET count, total, number, average, x to 0
Count =1
REPEAT
R
INPUT number
IF number > 0 THEN
Total = total + number
KU
X = x +1
ENDIF
Count = count + 1
UNTIL count = 10
AVERAGE = total/x
A
OUTPUT average
END
Example: Flowchart
TH
ED
HM
A
R
KU
A
TH
ED
HM
Purpose of this algorithm: To find the average of all positive numbers entered
Structured Programming: Programming that produces programs with clean flow, clear design, and
a degree of modularity or hierarchical structure.
R
amendments are easier to make because individual sections can be corrected without having to
work through the whole program.
KU
Methods of Solution for Pseudocodes:
Variables
Value/Variable Assignment
Operators
Arithmetic Operators
Relational Operators
Logical Operators
A
Statement: A program statement is a single instruction composed of its reserved words.
Expression: An expression is a set of variables, constants & operators (such as +, -, etc) that is to be
evaluated by the computer.
TH
Reserved Words: A reserved word is a name that has some special significance to the compiler or
interpreter. The programmer can only use it for its special purpose & can’t use it as an identifier.
Identifier: An identifier is a name invented by the programmer for some data. An identifier can be a
name for a variable, a constant, a file, an array, etc.
Variable: A variable is a quantity named in a program & whose value can change.
ED
Constant: A constant is a value that doesn’t change. In a program it may or may not be given a
name.
Assignment Operator/Symbol:
HM
Arithmetic Operators
A = 10
B = 20
OPERATOR PHRASE DESCRIPTION EXAMPLE
+
A
- Subtract Subtracts second operand from the first A - B will give -10
Relational Operators
A = 10
B = 20
OPERATOR PHRASE DESCRIPTION EXAMPLE
R
becomes true.
> Greater than Checks if the value of left operand is (A > B) is not
KU
greater than the value of right operand, if true.
yes then condition becomes true.
A
>= Greater than or
equal to
Checks if the value of left operand is
greater than or equal to the value of right
(A >= B) is not
true.
operand, if yes then condition becomes
true.
TH
<= Less than or equal
to
Checks if the value of left operand is less
than or equal to the value of right
(A <= B) is
true.
operand, if yes then condition becomes
true.
Logical Operators
A = 10
HM
B = 20
OPERATOR DESCRIPTION EXAMPLE
(A AND
Called Logical AND operator. If both the operands
AND B) is
are non-zero, then condition becomes true.
false.
Flowchart
A graphic map of the path of control or data through the operations in a program or an information-
handling system. Symbols such as squares, diamonds, and ovals represent various operations. These
symbols are connected by lines and arrows to indicate the flow of data or control from one point to
another.
OR
R
The block diagrammatic representation of the flow of program is known as Flowchart.
KU
SHAPE NAME SYMBOL PURPOSE
A
Parallelogram Input/output Box TH For Input and Output
For Selection
Rhombus Decision Box
IF condition
ED
HM
Testing
Testing is a method of checking whether the system/program/field is functioning appropriately
according the designed data requirements.
R
Test Data
Test data is data which has been specifically identified for use in tests, typically of a computer
program
KU
Testing carried out using the plan to make sure that all the parts of the system work correctly with
normal, extreme and erroneous data
Normal test data is used to check that a system can handle the sort of data that would be
expected during day-to-day use
Extreme test data is used to check that a system can cope with data that lies on the boundaries
of what is acceptable
A
Erroneous/Abnormal (or exceptional) test data is used to check that a system can identify data
that is wrong and reject it
Test input
Notmal Enter incorrect mark ‘45’ Mark accepted
markfunction
Test input
Abnormal Enter incorrect mark ‘–1 Mark rejected
markfunction
ED
i.e. 50
Understand the need for validation and verification checks to be made on input data (validation
could include range checks, length checks, type checks and check digits)
Validation
Validation is a process of checking if data satisfies certain criteria when input i.e. falls within
A
It is the checking of the type of data, i.e. the checking if the data is in
Type Check
the same type/format as it is required or not.
this checks whether data is within given/acceptable values e.g.
Range check
checks if a person’s age is > 0 but is also < 140.
this checks if the input data contains the required number of
Length check characters e.g. if a field needs 6 digits, then inputting 5 digits or 7
digits, for example, should be rejected.
this checks that the input data doesn’t contain invalid (type check)
Character check
characters; e.g. a person’s name shouldn’t contain numbers.
this checks that data is in a specified format (template) e.g. (picture
Format check
check) date should be in the form dd/mm/yyyy.
this is similar to a range check except only ONE of the limits
Limit check
(boundaries) is checked e.g. input data must be > 10.
check that data is actually present and not missed out e.g. in an
R
Presence check electronic form, somebody’s telephone number may be a required
field.
Consistency this checks if fields correspond (tie up) with each other e.g. if Mr. has
KU
check/ Cross field been typed into a field called “Title” then the “Gender” field must
check contain M or Male.
this is an extra digit added to a number which is calculated from the
Check digit digits; the computer re-calculates and validates the check digit
following input of the number (see next page).
(NOTE: check digits can identify 3 types of error:
(1) if 2 digits have been inverted e.g. 23459 instead of 23549
A
(2) an incorrect digit entered e.g. 23559 instead of 23549
(3) a digit missed out altogether e.g. 2359 instead of 23549)
TH
This section shows how check digits are calculated. The ISBN-10 (used on books) has been chosen
as the example; this uses a modulo 11 system which includes the letter X to represent the number 10.
Example 1
To calculate the check digit for the ISBN 0 - 2 0 1 - 5 3 0 8 2 - ?
(iii) the total is then divided by 11 (modulo – 11) and the remainder, if any is subtracted from 11 to
give the check digit.
98 ÷ 11 = 8 remainder 10
11 – 10 = 1
Example 2
To check the correctness of a check digit the computer re-calculates it as follows:
132 ÷ 11 = 12 remainder 0
Verification
Verification is a way of preventing errors when data is copied from one medium to another (e.g.
from paper to disk/CD, from memory to DVD, etc.). There are a number of ways in which verification
can be done:
Double entry: in this method, data is entered twice (using two different people); the data is only
accepted if both versions match up. Often used to verify passwords by asking them to be typed
in again by the same person.
Visual check: this is checking for errors by comparing entered data with the original document
(NOTE: this is not the same as proof reading!!).
Parity check: this is used to check data following potential transmission errors; an extra bit is added
R
to each binary number before transmission – e.g. EVEN parity makes sure each number has an even
number of 1 – bits;
KU
Example: if 11000110 is sent (four 1’s)
and 11100110 is received (five 1’s)
Use trace tables to find the value of variables at each step in an algorithm
A
Trace Table
A trace table is a technique used to test algorithms, in order to make sure that no logical errors occur
whilst the algorithm is being processed.
TH
A trace table is a true interpretation of understanding layers and levels of algorithms following the
steps of algorithm in a tabular form.
Set a,sum 0
WHILE a < 10 DO
a = a + 1
ED
sum = sum + a
ENDWHILE
OUTPUT sum
END
TRACE TABLE
HM
Conclusion: Using the trace table we had been able to see what is happening in each step of
algorithm until the algorithm ends, and to be able to see the result.
TIPS: 1. Must follow the sequence of Algorithm in the columns of Trace Table.
2. Always use the instructions with variables in the trace table.
The flowchart below inputs the weight of a number of parcels in kilograms. Parcels weighing more
than 25 kilograms are rejected. A value of –1 stops the input.
R
The following information is output: the total weight of the parcels accepted and number of parcels
rejected.
KU
A
TH
ED
HM
A
Method 1:
1 2 3 4 5 6
Input Weight = -1 Weight > 25
Total Reject Weight
Weight YES NO YES NO
R
Total
Reject
Output Goto =
=
Total, End Column total
Reject
Reject 6 +
KU
+ 1
weight
A
TH
ED
Solution:
HM
A
Identify errors in given algorithms and suggest ways of removing these errors
R
Read this section of program code that should input 30 positive numbers and then output the largest
number input.
KU
1 Large = 9999
2 Counter = 0
3 WHILE Counter > 30
4 DO
5 INPUT Num
6 IF Num < Large THEN Large = Num
A
7 Counter = Counter - 1
8 ENDWHILE
9 PRINT Large
Error 1:
Large Counter Counter > 30 Input Num IF Num < Large Counter =
Then Counter -1
Large = Num
9999 0 FALSE () - - -
ED
Corrected
Large Counter Counter < 30 Input Num IF Num < Large Large
Then
Large = Num
Line 3
HM
Error 2:
Large Counter Counter < 30 Input Num IF Num < Large Counter =
Then Counter -1
Large = Num
9999 0 TRUE () - - -
Then Counter -1
Large = Num
0 0 TRUE () - -
Line 1
Error 3:
Large Counter Counter < 30 Input Num IF Num < Large Counter =
Then Counter -1
Large = Num
0 0 TRUE () -26 Large = -26 -
Corrected: To filter larger number, the number must be checked for greater (>) than larger.
R
Large Counter Counter < 30 Input Num IF Num > Large Counter =
Then Counter -1
Large = Num
0 0 TRUE () 26 Num > Large
KU
26 > 0
Large = 26
Line 6
Error 4:
A
Large Counter Counter < 30 Input Num IF Num > Large Counter =
Then Counter -1
Large = Num
0 0 TRUE () 26 Large = 26 Counter = -1
TH
Corrected: To run loop 30 times, the counter must go from 0 to 30. If the counter is decremented 1
value from 0 i.e. 0, -1, -2…. Then the loop never ends.
Large Counter Counter < 30 Input Num IF Num > Large Counter =
Then Counter + 1
Large = Num
0 0 TRUE () 26 Large = 26 Counter = 1
26 1 TRUE () 65 Large = 65 Counter = 2
65 2 TRUE () 45 - Counter = 3
65 3 TRUE () 77 Large = 77 Counter = 4
ED
- Line 7
Solution:
Line 1 or Large =9999: this should read Large = 0
Line 3 or WHILE: this should read WHILE Counter < 30
HM
Line 6 or IF: this should read IF Num > Large THEN Large = Num
Line 7 or Counter =…: this should read Counter = Counter + 1
A
Produce an algorithm for a given problem (either in the form of pseudocode or flowchart)
R
Write an algorithm, using pseudocode or a flowchart, which:
inputs all the sound levels
after a sound level of 0 is input, outputs the following:
KU
average sound level
highest recorded sound level
Solution: (Pseudocode)
total = 0: highest = 0: count = 0
A
INPUT sound
WHILE sound > 0 DO
total = total + sound)
IF sound > highest THEN highest = sound
count = count + 1
INPUT sound
TH
ENDWHILE
average = total/count
Print average, highest
444 Yodafone
555 N2 network
666 Kofee mobile
777 Satsuma mobile
HM
Write an algorithm, using pseudocode or flowchart only, which reads 50 000 eight-digit mobile phone
calls made during the day and outputs the number of calls made on each of the four networks.
Solution:
Y = 0: N = 0: K = 0: S = 0
There are many different solutions to the same problem. In order to consider the effectiveness of a
given solution ask the following questions.
R
Are any actions repeated more often than necessary?
Can the solution be simplified and still work as well?
KU
A
TH
ED
HM
A