Problem Solving
Computational thinking and algorithms
Decomposition: Break big problems into smaller sub-problems. **Abstraction:** Remove unnecessary detail, focus on what matters.
Flowcharts: Oval = Start/End. Rectangle = Process. Diamond = Decision. Parallelogram = Input/Output.
Pseudocode: Structured plain English using INPUT, OUTPUT, IF...THEN...ELSE, WHILE, FOR.
Sorting: **Bubble sort** — compare adjacent, swap if wrong order. O(n²). **Merge sort** — split, sort halves, merge. O(n log n).
Searching: **Linear search** — check each item. Works on unsorted data. **Binary search** — sorted data only. Check middle, discard half. O(log n).
Trace tables: Track variable values step by step as an algorithm executes.
Key Points to Remember
- 1Decomposition and abstraction
- 2Flowcharts and pseudocode
- 3Sorting and searching algorithms
- 4Trace tables
Pakistan Example
NADRA's Database — Binary Search at National Scale
NADRA manages 120+ million citizen records. When police verify a CNIC, binary search finds the record in milliseconds instead of checking all entries. Without efficient algorithms, verification would take hours.