Practical Theory Notes AS
Practical Theory Notes AS
Algorithms can be documented by a program designer using English, program flowcharts, and
pseudocode.
When to present : when designing a solution to a problem
Purpose : to describe a solution as a sequence of steps.
Problem Decomposition: Breaking a problem down into sub-tasks. This is done to make the
problem easier to solve. It makes the solution easier to test,and can be solved separately.
TYPE <TypeIdentifier>
DECLARE <field identifier> : <data type>
.
ENDTYPE
E.g
TYPE Node
DECLARE data : INTEGER
Declare next : INTEGER
ENDTYPE
Arrays
Array: A structure for the temporary storage of data
Array index: row or column number of an individual array element
Upper bound: the highest number index of an array dimension
Lower bound: the smallest number index of an array dimension
Linear Search: checking each element of an array in turn for a required value
Basic DataTypes
Constructs of an algorithm:
● Sequence: Instructions/lines of code are executed in a fixed order.
● Assignment: A value is given to a variable
● Selection: Testing a condition to determine the sequence of execution//path of program
execution.
● Repetition/Iteration: A method of executing certain lines of code more than once
Types of loops:
● Count-controlled: the number of iterations is known/fixed e.g FOR
● Post Condition: the number of iterations depends on some condition being tested at the
end. The loop is executed at least once. E.g Repeat
● Pre Condition: the number of iterations depends on some condition being tested at the
beginning. The loop may never be executed. E.g While
procedure interface
-Provides a mechanism to allow calling program to pass data
-Defines the parameters of the procedure
-giving their data type and order
Software Development
Software Development Cycle:
1) Problem Definition/ Analysis
2) Design
3) code/implementation (e.g writing code)
4) Testing (e.g normal ,abnormal)
5) Maintenance
Purpose of upward & downward arrows :
- Upward arrows: more work is required at a previous stage to complete the
current stage
- Downward arrows: result from one stage is passed to the next
Main decisions in Design stage :
- Programming language
- Data structure
- Use of library routines (Functions)
- Testing methods
- Abstraction : removing information that is not essential, for quicker design
Benefits:
● Simple to understand as the stages are clearly defined.
● Easy to manage due to the fixed stages in the model. Each stage has specific outcomes.
● Stages are processed and completed one at a time.
Drawbacks:
● No working software is produced until late during the life cycle.
● Not a good model for complex projects.
● Poor model for long and ongoing projects.
● Integration is done at the very end, which doesn’t allow identifying potential technical or
business issues early.
The Iterative Model
development starts with implementing a small part of requirements. Repeated (iterative) reviews
to identify further requirements eventually result in the complete system.
Types of iterative
In the RAD model, the modules are developed in parallel as prototypes and are integrated
to make the complete product for faster product delivery..
The analysis, design, code and test phases are incorporated into a series of short, iterative
development cycles.
Drawbacks:
● Only systems that can be modularised can be built using RAD.
● Requires highly skilled developers/designers.
● Requires user involvement throughout the life cycle.
Finite state machine (FSM): a machine that consists of a fixed set of possible states with a set
of inputs that change the state and a set of possible outputs
State-transition table: a table that gives information about the states of an FSM
Testing:
Stub testing: Testing may be carried when modules not yet ready for full testing. Module stubs is
is replaced with simple code that provide a known response(return or output).
Black-box testing: A testing method used when the structure of the program is unknown. Can
reveal:
● Run-time error
● Logical error
● The algorithm is incorrect. Incorrect calculator performed
White-box testing: Testing all possible paths through the code. Normal, boundary and
erroneous data are used for testing.
Dry run (Walkthrough): the process of checking the execution of an algorithm or program by
recording variable values in a trace table,all paths through the program can be tested. A trace
table a table with a column for each variable that records their changing values.
Integration testing: Tested by the programmer ortesters when modules have been tested
individually, they combine modules and test them as a whole ,to ensure the modules work
together as expected.
Alpha testing: Tested by the programmer or in-house testers near the end of development after
integration testing and before beta testing. This is done to find errors not found in earlier testing
and to ensure the software is ready for beta.
Beta testing: Tested by a small selection of potential end-users or clients before the general
release of the software. This is done to receive constructive feedback when tested in real-life
scenarios. It ensures that the software is ready for release.
si
Acceptance testing: Tested by the end-user of the software when the software is finished to
ensure the software is what the customer ordered and if meets the user requirements.
Abnormal (erroneous): Data values that the system should not accept
Boundary (extreme): Data values that are at a boundary or an extreme end of the range of
normal data; test data should include values just within the boundary (that is, valid data) and just
outside the boundary (that is, invalid data)
Types of errors:
● Syntax error: A statement in the source code that breaks the rules of the language
● Logic error: An error in the algorithm that causes the program not to behave as intended
● Run-time error: A program performs an invalid operation. Examples: Tries dividing by
zero; enters an infinite loop; stops unexpectedly.
Program fault: Something that makes the program not do what it is supposed to do, under
certain circumstances.
Testing techniques:
Single stepping:
● Executes a line of code at a time
● Use to trace the path of execution (sequence)
● Track variable values using a watch window
Using identifier names such as I1, I2, and I3 is not a good practice because the names are not
meaningful. It is easy to use the wrong identifier names. This makes the program more difficult to
understand/debug/modify/test.
Advantage of using text files rather than arrays: The data is retained when the program is
terminated.
Stacks: Abstract data structure that works with concept LIFO(last in first out)
Consists of 1d array, front of queue pointer,end of queue pointer
Queues:Abstract data structure that works with concept FIFO(first in first out)
Consists of 1d array, Topofstackpointer , number of items stored
Linked Lists:
Node: an element of a list
Pointer: a variable that stores the address of the node it points to
Null pointer: a pointer that does not point at anything
Start pointer: a variable that stores the address of the first element of a linked list