7. Algorithm Design and Problem-Solving Flashcards
Analysis
identify the problem and its requirements
Design
develop an algorithm to solve the problem by using structure diagrams, flowcharts or pseudocode
Coding
write and implement the instructions to solve the problem
Testing
detect and fix the errors in the program
Sub-systems of a computer
- CPU
- memory
- storage
- input devices
- output devices
Component parts after a problem has been decomposed
- inputs
- processes
- outputs
- storage
Methods to design and construct a solution to a problem
- structure diagrams
- flowcharts
- pseudocode
Standard methods of solution
- linear search
- bubble sort
- totalling
- counting
- finding maximum, minimum and average values
Features that should be included to create a maintainable program
- meaningful identifiers…
- …to enable to programmer to easily recognise the purpose
- …of variables, constants, arrays, procedures etc.
- …by example
- use of comments…
- …to annotate each section of a program so that a programmer can find specific sections/so the programmer knows the purpose of that section of code
- …for example logic/syntax
- procedures and functions…
- …to avoid repeated code
- …to simplify logic
- …to make programs modular and easier to update
- use indentation and white space…
- …to make the program readable
Purpose of ROUND
- to return a number rounded to a specific number of decimal places
- the result will either be rounded to the next highest or lowest value
- …depending on whether the value of the preceding digit is >5 or <5
- example
Purpose of MOD
- to perform (integer) division when one number is divided by another
- …to find the remainder
- example
Purpose of RANDOM
- to generate (pseudo) random numbers
- …(usually) within a specific range
- example
Data validation
- an automated check carried out by a computer
- …to make sure the data entered is sensible/acceptable/reasonable
Validation checks
- range check
- length check
- type check
- presence check
- format check
- check digit
Verification checks
- visual check
- double entry check
Why verification checks are used
- to ensure that data has been accurately copied/are entered as intended
- …from one source to another
Validation vs verification
- validation ensures that data is sensible and allowable
- verification ensures that data entered is the same as the original/intended
Types of test data
- normal
- abnormal
- extreme
- boundary
Purpose of test data
- check that the program works as expected
- check for logic/runtime errors
- check that the program rejects any invalid data that is input
- check that the program only accepts reasonable data
Purpose of using procedures
- to enable the programmer to write a collection of programming statements under a single identifier
- to allow modular programs to be created/to allow procedures to be re-used within the program or in other programs
- to make program creation faster because procedures can be re-used/to enable different programmers to work on different procedures in the same project
- to make programs shorter, making it easier to maintain
Purpose of using parameters
- to pass values from the main program to a procedure/function
- …so that they can be used in the procedure/function
- allow the procedure/function to be used with different data
Abstraction
- simplifying the problem
- removing unnecessary details from the problem/selecting elements required
- filtering out irrelevant characteristics from those elements
Reasons for storing data in a file
- data is stored permanently
- data can be moved onto another computer
- data can be used by more than one program/can be reused when a program is run again
- another copy of the data can be made and stored/accessed elsewhere/backup copy