Skip to main content

🧩 ALGORITHM DESIGN & PROBLEM-SOLVING

1️⃣ Program Development Life Cycle (PDLC)

You must know the four stages and what happens in each.

🔹 1. Analysis

This is understanding the problem.

Includes:

✅ Identifying the problem

  • What needs to be solved?
  • Who will use the system?

✅ Requirements

  • What inputs?
  • What outputs?
  • What processing?
  • What storage?

✅ Abstraction

Removing unnecessary detail and focusing only on what matters.

Example:
If designing a student grading system:

  • Ignore student hobbies.
  • Focus on marks, names, averages.

✅ Decomposition

Breaking a large problem into smaller sub-problems.

Example:
School system →

  • Input marks
  • Calculate average
  • Assign grade
  • Display result

🔹 2. Design

Planning the solution before coding.

Includes:

  • Structure diagrams
  • Flowcharts
  • Pseudocode

You design:

  • Inputs
  • Processes
  • Outputs
  • Storage

🔹 3. Coding

  • Writing the actual program.
  • Uses a programming language.
  • Includes iterative testing (testing as you code).

🔹 4. Testing

  • Use test data.
  • Identify errors.
  • Fix bugs.

2️⃣ Sub-systems & Decomposition

🔹 Computer Systems Have Sub-systems

Large systems are made of smaller systems.

Example: School system

  • Attendance system
  • Results system
  • Library system

Each can be broken down further.

🔹 Decomposition

Breaking a problem into smaller parts makes it:

  • Easier to manage
  • Easier to test
  • Easier to debug

This is frequently examined.

3️⃣ Methods of Designing Algorithms

You must know three:

🔹 1. Structure Diagrams

  • Show system broken into modules.
  • Hierarchical structure.
  • No logic shown.

🔹 2. Flowcharts

Use standard symbols:

SymbolMeaning
OvalStart/End
ParallelogramInput/Output
RectangleProcess
DiamondDecision
ArrowFlow line

🔹 3. Pseudocode

  • Structured English.
  • Uses programming style.
  • Must be precise.

4️⃣ Inputs, Processes, Outputs, Storage (IPOS)

Every system includes:

Input

Data entered.

Process

What happens to the data.

Output

Result produced.

Storage

Data saved for later use.

5️⃣ Standard Methods of Solution (Very Important)

These are guaranteed exam areas.

Searches through a list one item at a time.

Algorithm:

Used when:

  • Data is unsorted.

🔹 2. Bubble Sort

Sorts by repeatedly swapping adjacent values.

Steps:

  1. Compare first two values.
  2. Swap if wrong order.
  3. Repeat.
  4. Largest value "bubbles" to end.

🔹 3. Totalling

Adds values together.

🔹 4. Counting

Counts occurrences.

🔹 5. Maximum / Minimum

Maximum:

🔹 6. Average

6️⃣ Validation & Verification

Very common 6-mark question.

🔹 Validation

Checks that data is sensible and acceptable.

Types:

TypeMeaning
Range checkValue within limits
Length checkCorrect number of characters
Type checkCorrect data type
Presence checkNot left blank
Format checkCorrect pattern (e.g. email)
Check digitMathematical check (e.g. barcodes)

🔹 Verification

Checks data was entered correctly.

Types:

TypeMeaning
Visual checkHuman checks data
Double entryData entered twice and compared

⚠️ Key difference:

Validation → Is data sensible?
Verification → Was data entered correctly?

7️⃣ Test Data

You must know 4 types.

🔹 Normal Data

Valid input within range.

Example:
Age 18 (range 0–120)

🔹 Abnormal Data

Invalid data.

Example:
Age = -5

🔹 Extreme Data

Largest/smallest acceptable value.

If range 0–120:

  • 0
  • 120

🔹 Boundary Data

Largest/smallest acceptable AND corresponding rejected.

If range 0–120:

  • 0 (accepted)
  • -1 (rejected)
  • 120 (accepted)
  • 121 (rejected)

Boundary questions are common.

8️⃣ Trace Tables & Dry Runs

Used to:

  • Track variables
  • Identify logic errors

Trace tables include:

| Step | Variable | Output |

You simulate the algorithm manually.

9️⃣ Errors in Algorithms

You must identify and correct:

🔹 Logical Errors

Program runs but wrong output.

🔹 Syntax Errors

Wrong structure (in code).

🔹 Runtime Errors

Occurs during execution (e.g. divide by zero).

🔟 Writing Algorithms

When writing pseudocode, always include:

  • Variables
  • User prompts
  • Inputs
  • Processing
  • Outputs

Example:

⚠️ Precision Rules (Exam Critical)

Correct:

Use symbols:

✏️ Exam Strategy Tips

🔹 1. For 6–8 Mark Algorithm Questions

Include:

  • Initialization of variables
  • Clear loops
  • Proper indentation
  • End statements (ENDIF, NEXT)

🔹 2. For Test Data Questions

Always provide:

  • Value
  • Expected result

🔹 3. For Trace Tables

Be slow and careful.
Marks are often 4–6 here.

🔹 4. Always Initialize Variables

📌 Quick Revision Summary

You must confidently understand:

✅ PDLC stages
✅ Decomposition
✅ Structure diagrams
✅ Flowcharts
✅ Pseudocode
✅ Linear search
✅ Bubble sort
✅ Totalling, counting
✅ Max, min, average
✅ Validation vs Verification
✅ Test data types
✅ Trace tables
✅ Error correction