IGCSE COMPUTER SCIENCE
ALGORITHM DESIGN, PROBLEM SOLVING & PSEUDOCODE
SUPER EASY NOTES + MEMORY TIPS
------------------------------------------
1. What an Algorithm Is
------------------------------------------
An algorithm is a clear list of steps used to solve a problem.
Memory Tip:
Think of an algorithm as a recipe. If your friend followed your steps and gets the same result, it's a good
algorithm.
------------------------------------------
2. Variables and Data
------------------------------------------
A variable stores a value in memory.
Examples:
- total ← 0 (total is a variable)
- name ← "Ray"
Memory Tips:
- INPUT: You receive something. (User → Computer)
- OUTPUT: You send something out. (Computer → User)
- ASSIGNMENT (←): You store or update a value.
------------------------------------------
3. IF, ELSE, ELSEIF Explained
------------------------------------------
IF condition THEN
statements
ELSEIF another condition THEN
statements
ELSE
statements
ENDIF
Explanation:
- IF checks the first condition.
- ELSEIF checks another condition if the first is false.
- ELSE runs when all conditions are false.
- ENDIF closes the decision.
Memory Tip:
IF = “Is this true?”
ELSE = “If not, then do this.”
ELSEIF = “If that’s not true, try this one.”
------------------------------------------
4. Loops
------------------------------------------
Loops repeat code.
A. Count-controlled loop (FOR)
FOR i ← 1 TO 5
OUTPUT i
NEXT i
Memory Tip:
FOR = “Repeat a known number of times.”
i is the counter that goes up every loop.
B. Condition-controlled loop (WHILE)
WHILE answer <> "yes"
INPUT answer
ENDWHILE
Memory Tip:
WHILE = “Keep going until the condition becomes false.”
------------------------------------------
5. Common Algorithms
------------------------------------------
A. Sum of Numbers
sum ← 0
FOR i ← 1 TO 5
sum ← sum + i
NEXT i
What each variable does:
- i counts each loop.
- sum stores the running total.
B. Find Largest Number
largest ← numbers[1]
FOR i ← 2 TO 10
IF numbers[i] > largest THEN
largest ← numbers[i]
ENDIF
NEXT i
C. Count Positive Items
count ← 0
FOR each value
IF number > 0 THEN
count ← count + 1
ENDIF
NEXT
D. Sentinel Loop (Until -1)
sum ← 0
count ← 0
INPUT mark
WHILE mark <> -1
sum ← sum + mark
count ← count + 1
INPUT mark
ENDWHILE
Memory Tip:
Sentinel value = special value that STOPS the loop.
(-1 NEVER gets added.)
------------------------------------------
6. Trace Tables
------------------------------------------
Used to test the logic manually.
Memory Tip:
Update each row every time a variable changes.
------------------------------------------
7. Flowchart Shapes
------------------------------------------
- Start/End: Oval
- Input/Output: Parallelogram
- Process: Rectangle
- Decision: Diamond
Memory Tip:
Diamond = “Do I choose yes or no?”
------------------------------------------
8. Extra Memory Tips for Pseudocode
------------------------------------------
- INPUT = “User tells the computer something.”
- OUTPUT = “Computer tells you something.”
- ← (assign) = “Become this value now.”
- IF = compare something.
- FOR = repeat a set number of times.
- WHILE = repeat until condition stops being true.
- VARIABLE = a “box” that stores information.
------------------------------------------
9. Extra Algorithm Tips
------------------------------------------
- Think step-by-step.
- Never assume the computer “knows” what you mean.
- Use clear names: total, count, mark.
- When stuck, write it as plain English first.