Algorithm Design and Problem Solving -
Notes
Program Development Life Cycle
Consists of: Analysis, Design, Coding, Testing.
It is a cycle, not a linear process. Revisions often needed during development.
Computer Systems and Sub-Systems
Composed of software, data, hardware, communications, and people.
Systems are broken down into sub-systems until each part performs a single action.
Example: Instagram - software (code), data (user preferences), hardware (servers),
communications & people (staff).
Structured Diagram (Top-Down Design)
Used to divide systems into sub-systems.
Example: Alarm clock - Inputs: Set Time, Processes: Check Time, Turn On/Off Alarm,
Outputs: Sound Alarm.
Algorithms
A set of instructions for solving a problem or performing a task.
Can be expressed using pseudocode or flowcharts.
Real-life example: Driving a car. Software example: Alarm checking if time and day
match.
Flowchart Components
Terminator: Start/End of process.
Process: Represents an action/instruction.
Input/Output: Data input or information output.
Decision: Used to decide next step, has two outcomes.
Subroutine: Represents a procedure within a program.
Flowline: Arrows indicating the flow of the algorithm.
Flowchart Design Examples
Example 1: Multiply two numbers, output if result > 100, repeat until user stops.
Example 2: Ticket purchase system – apply 10% discount for ≥10 tickets, 20% for ≥20.
Max 25 tickets.
Validation and Verification
Validation ensures input data is reasonable:
- Range Check: Value within limits.
- Length Check: Data has correct length.
- Type Check: Correct data type.
- Presence Check: Field is not blank.
- Format Check: Data matches specific pattern.
Verification ensures data is correctly entered:
- Double Entry, - Visual Check.
Testing Types
Normal Data: Expected valid input.
Extreme Data: Largest/smallest valid values.
Abnormal Data: Invalid data that should be rejected.
Boundary Data: Test values just inside and just outside valid range.
Debugging with Trace Tables and Test Data
Trace Tables: Track variable changes step-by-step to find errors.
Use test data to verify algorithm correctness (e.g., ticket cost with discount).