Chapter7 - Algorithm design and problem solving

7.01 Program development life cycle

7.02 Computer systems, sub-systems and decomposition

Each computer system is made up of software, data, hardware, communications and people.

Each computer system can be divided up into a set of sub-systems and each sub-system can be further divided into subsystems and so on until each sub-system just performs a single action.

The process of decomposition into sub-systems so that a system can be more easily represented and understood is the basis of top-down design.

Any problem that uses a computer system for its solution needs to be decomposed into its component parts. These are inputs, processes, outputs and storage.

Any problem that uses a computer system for its solution needs to be decomposed into its component parts. These are inputs, processes, outputs and storage.

  1. structure diagrams
  2. flowcharts
  3. pseudocode.

Structure diagrams

A structure diagram shows hierarchically how each computer system can be divided up into a set of sub-systems.

Flowcharts

A flowchart shows diagrammatically the steps required to complete a task and the order that they are to be performed. These steps, together with the order, are called an algorithm.

Pseudocode

Pseudocode is a simple method of showing an algorithm. It describes what the algorithm does by using English key words that are very similar to those used in a high-level programming language and meaningful identifier names.

Mathematical operators

Pseudocode statements


Comparison operators

Explaining the purpose of an algorithm

Standard methods of solution

Totalling

counting

Finding maximum, minimum, average

Linear search

Bubble sort

Validation and verification

For data entry, validation ensures that only data that is reasonable is accepted. Verification is used to check that the data does not change as it is being entered. Different types of checks may be used on the same piece of data.

Test data

Test data ensures that an algorithm works as expected, completing all parts of the solution with no errors.

It is used with trace tables to check pseudocode and flowcharts work as expected. Sets of test data are used with programs to ensure outputs are as expected.

Trace tables

A trace table records the results from each step in an algorithm; it shows the value of each variable every time that it changes. Working through an algorithm step by step is called a dry run.