Algorithm Design And Problem-solving: Write And Amend Algorithms For Given Problems Or Scenarios, Using: Pseudocode, Program Code And Flowcharts (Copy)
Algorithm Design And Problem-Solving
Write And Amend Algorithms For Given Problems Or Scenarios, Using: Pseudocode, Program Code And Flowcharts
What “Write And Amend Algorithms” Usually Means In Exams
| Task Type | What You Are Given | What You Must Produce | Core Skill Being Tested |
|---|---|---|---|
| Write algorithm | Problem statement + constraints | Full working solution | Correct logic + correct structure |
| Amend algorithm | Faulty/unfinished algorithm | Corrected / improved version | Debugging + logic repair |
| Complete missing parts | Part-written algorithm | Fill blanks correctly | Understanding control flow |
| Convert form | Flowchart ↔ pseudocode ↔ code | Equivalent version | Translation accuracy |
| Trace + fix | Inputs + expected outputs | Identify mismatch + amend | Testing + correction |
Writing A Strong Algorithm — The 6-Step Build Pattern
| Step | What You Do | Quick Reminder |
|---|---|---|
| 1. Identify inputs | List what user/system provides | Name variables clearly |
| 2. Identify outputs | Decide final result(s) | Output exactly what asked |
| 3. Choose data types | INTEGER/REAL/STRING/BOOLEAN/ARRAY | Don’t mix types |
| 4. Pick structures | IF / loops / arrays | Use simplest structure |
| 5. Write pseudocode first | Clean, structured logic | Easier to debug |
| 6. Test with data | Normal, boundary, invalid | Match question constraints |
Pseudocode — Examiner-Friendly Rules
| Rule | What To Do | Common Mistake |
|---|---|---|
| Indentation | Indent inside IF/loops | Flat, unreadable blocks |
| Clear keywords | IF…THEN…ENDIF, FOR…NEXT, WHILE…ENDWHILE | Mixing real-language syntax |
| Consistent variable names | Use same name everywhere | Renaming mid-solution |
| Initialise | Set counters/totals to 0 | Using before assignment |
| Input before processing | Always INPUT first | Calculating on empty value |
| Output at the end | Unless question wants live output | Printing inside loops by accident |
Written and Compiled By Sir Hunain Zia, World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change O Level And IGCSE Computer Science Full Scale Course
Standard Pseudocode Templates (Use These Fast In Exams)
| Problem Pattern | Template Logic | Typical Use |
|---|---|---|
| Count items | count ← 0 then increment when condition true |
Count passes/fails, count even numbers |
| Total / sum | total ← 0 then add values |
Sum marks, total price |
| Average | average ← total / n |
Mean score, mean temperature |
| Max / min | Start with first value then compare | Highest score, lowest temperature |
| Validation loop | Repeat input until valid | Range checks (1–10), non-empty string |
| Sentinel loop | Keep looping until stop value entered | “Enter -1 to end” |
Amending Algorithms — High-Frequency Fixes
| Fault Seen | Why It Breaks | Quick Fix |
|---|---|---|
| Wrong loop limits | Missed/extra iteration | Adjust start/end (off-by-one) |
| Control variable not updated | Infinite loop | Update inside loop |
| Condition reversed | Wrong branch runs | Flip comparison / fix logical operator |
| Output wrong variable | Output doesn’t match expected | Replace with correct variable |
| Total not reset | Old values leak into new run | Re-initialise totals/counters |
| Division by zero risk | Crash runtime | Validate before dividing |
Flowcharts — How To Write + Amend Quickly
| Flowchart Symbol | Meaning | Common Error | Fix |
|---|---|---|---|
| Oval | Start / End | Missing END | Add END terminator |
| Parallelogram | Input / Output | Using process box for input | Replace with I/O symbol |
| Rectangle | Process / calculation | Putting decisions here | Use diamond for decisions |
| Diamond | Decision (Yes/No) | More than 2 exits | Split into multiple decisions |
| Arrow | Flow direction | Crossing lines confusion | Re-route neatly / use connectors |
Written and Compiled By Sir Hunain Zia, World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change O Level And IGCSE Computer Science Full Scale Course
Translating Between Pseudocode, Code, Flowchart — Accuracy Checklist
| Conversion | Must Preserve | Common Slip |
|---|---|---|
| Flowchart → pseudocode | Order, decisions, loop conditions | Dropping a loop back-arrow logic |
| Pseudocode → code | Same logic + correct syntax | Changing meaning of conditions |
| Code → flowchart | Exact branches + termination points | Missing a branch / missing END |
Program Code — What Examiners Usually Want (Not Fancy Code)
| Feature | Do This | Avoid This |
|---|---|---|
| Readability | Simple variables, clear steps | Complex shortcuts |
| Correctness | Matches scenario exactly | Over-generalising |
| Validation | Only if asked / needed to prevent crash | Adding unnecessary layers |
| Loops | Use the simplest loop that fits | Nested loops when not required |
| Output | Same format as question expects | Extra messages not asked |
Quick Debugging Method For Amend Questions (3 Pass System)
| Pass | What You Check | What You Catch |
|---|---|---|
| Pass 1: Inputs/Outputs | Are correct values read and shown? | Wrong variable used, missing input |
| Pass 2: Control Flow | Do IF/loops match scenario? | Wrong condition order, infinite loops |
| Pass 3: Boundaries | Test smallest/largest values | Off-by-one, division by zero |
Written and Compiled By Sir Hunain Zia, World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change O Level And IGCSE Computer Science Full Scale Course
Mini “Amend This” Common Scenarios
| Scenario | Fault That Often Appears | Correct Amendment |
|---|---|---|
| “Repeat until valid input” | Uses IF once only | Replace with loop until valid |
| “Find maximum of 10 numbers” | max ← 0 (fails with negatives) |
Set max to first input |
| “Average of n numbers” | Divides inside loop repeatedly | Divide once at end |
| “Stop when -1 entered” | Still adds -1 into total | Check sentinel before processing |
Examiner Marks — Where They Actually Come From
| Mark Area | What Gets Marks | What Loses Marks |
|---|---|---|
| Correct structure | Right IF/loop choice | Wrong loop type or missing ENDs |
| Correct logic | Condition matches scenario | Condition reversed / incomplete |
| Correct updates | Counters/totals updated correctly | Missing increment / wrong variable |
| Correct outputs | Output exactly required | Output extra / wrong format |
| Amend precision | Fix only the wrong parts | Rewriting whole thing unnecessarily |
Written and Compiled By Sir Hunain Zia, World Record Holder With 154 Total A Grades, 7 Distinctions and 11 World Records For Educate A Change O Level And IGCSE Computer Science Full Scale Course
