Computer Science (2210)
Flowcharts: Visual diagrams using shapes Oval: Start/End Rectangle: Process (doing something) Diamond: Decision (Yes/No question) Parallelogram: Input/Output Arrows: Flow direction
Pseudocode: Structured English that looks like code but isn't a real programming language
INTEGER: whole numbers (age = 17) REAL: decimal numbers (price = 99.99) STRING: text (name = "Ahmed") BOOLEAN: true/false (passed = TRUE)
FOR loop: When you know how many times (FOR i = 1 TO 10) WHILE loop: When you don't know (WHILE answer != "quit") REPEAT...UNTIL: Runs at least once
Linear search: Check each item one by one Bubble sort: Compare pairs, swap if in wrong order, repeat Totalling: Add up values in a loop Counting: Count items that meet a condition Finding max/min: Track the highest/lowest value seen
Topic 5 of 5Cambridge O Levels
Algorithms & Programming
Problem solving with flowcharts, pseudocode, and code
An algorithm is a step-by-step set of instructions to solve a problem.
Representing Algorithms:
Key Programming Concepts:
Variables: Named storage locations for data
Selection (IF statements):
IF score >= 50 THEN
OUTPUT "Pass"
ELSE
OUTPUT "Fail"
ENDIF
Iteration (Loops):
Common Algorithms:
Key Points to Remember
- 1Flowchart shapes: Oval=start/end, Diamond=decision, Rectangle=process
- 2Variables store data: INTEGER, REAL, STRING, BOOLEAN
- 3Selection = IF/ELSE, Iteration = FOR/WHILE loops
- 4Linear search checks one by one, Bubble sort swaps adjacent pairs
Pakistan Example
Finding the Shortest Rickshaw Route
Imagine you're in Saddar, Karachi, and need to find the cheapest rickshaw to Clifton. You could use a linear search: ask each rickshaw wala his fare (150, 200, 120, 180, 130) and keep track of the minimum. In pseudocode: min = 999, FOR each fare: IF fare < min THEN min = fare. Result: 120. Google Maps uses much more complex algorithms (Dijkstra's algorithm) to find the shortest route, considering distance, traffic, and road conditions. But the basic logic is the same — compare and track the best option!