Please enable JavaScript.
Coggle requires JavaScript to display documents.
COMPUTER SCIENCE - ALGORITHM DESIGN AND PROBLEM SOLVING - CHAPTER 13 / 2.1…
COMPUTER SCIENCE - ALGORITHM DESIGN AND PROBLEM SOLVING - CHAPTER 13 / 2.1.1
SUB SYSTEMS
Computer systems consist of sub-systems. These sub-systems can have sub-systems of their own.
Subroutine - a short section of code within a program.
Library routine - a commonly used function that is available to a programmer. Contains commonly used programs and subroutines that can be used in another program.
TOP-DOWN DESIGN AND STRUCTURE DIAGRAMS
Algorithms are step-by-step designs that describe how systems and sub-systems work. Algorithm design methods include: top-down design, structure diagrams, flowcharts and pseudocode.
Top down design is a design method where a problem is broken down into smaller problems.
Structure diagrams are used to show how modules fit together and relate to each other. Shows tasks that have been broken down.
Decomposition - the process of breaking down a large task into smaller tasks.
Module - an individual section of code that can be used by other programs.
A computer system is referred to as a 'complex problem' and the sub-systems within a system are referred to as 'sub-problems'.
Structure diagram example -
With top-down design algorithms can be developed more quickly as more than one person can work to solve the problem, modules can be reused in different programs with similar structures, structure diagrams allow us to easily visualise how a program will work and how the modules relate to one another, structure diagrams make it easier for other designers to understand the logic of an algorithm.
STANDARD METHODS OF SOLUTION
FLOWCHARTS
Flowcharts represent the structure and flow of an algorithm.
Advantages - easy to see the sequence of steps, easy to follow the paths through the algorithm, the logic of the algorithm is easier to understand visually, help others easily understand how a program works.
Disadvantages - take a lot of time to produce, re-drawing a flowchart is usually needed when changing the algorithm, large flowcharts can become complicated and less easy to follow.
PSEUDOCODE
Pseudocode is a text based method of describing how an algorithm works.
TEST DATA
Test data is used to test a program. A test table documents the results of testing.
For test data three types of data should be used: normal data (for 1-100, 34); extreme data (for 1-100, 98); and invalid data (for 1-100, 123).
VALIDATION AND VERIFICATION
It is impossible to guarantee that data entered is error free but validation and verification checks help reduce errors.
Validation checks make sure data entered is sensible and possible, for example a range check (making sure entered data is numerical and between certain numbers) and a presence check (makes sure that a field has to have data entered into, like when entering a password.
Verification tries to ensure that data entered is correct. The main ways of this are: double entry, twin entry (by two users with the same data), and proofreading (where the second user checks the data.
Check digits are a form of validation that carries out a series of calculations to ensure numerical data is correct, like adding the number of digits and putting the total number at the start of the number.
TRACE TABLES
Dry run - a paper-based manual run through of an algorithm or program.
Trace tables allow a programmer to easily pinpoint where errors are, but can be extremely long and time consuming to produce.
Trace table - a table used to trace the values of variables through the execution of a program. All new values are placed on a new line unlike most tables.
ERRORS IN A PROGRAM
Syntax errors occur when the programmer enters a code that does not follow the rules of the programming language. Occur if; the line is incomplete; the line contains spelling errors; and if the elements are in the wrong order.
Logic errors occur where the programmer writes code that does not perform as intended or does something unexpected. Examples of these include; infinite conditional loops; assignment of the wrong data to a variable; using the same variable name for different purposes.