Steps of problem solving
- Analyse the problem: understand what is given (input), what is wanted (output) and the rules.
- Develop an algorithm: write the solution as clear, ordered steps.
- Code: turn the algorithm into a program in a language like Python.
- Test: run it with many inputs, including edge cases (0, negative numbers, very large values).
- Debug: find and fix errors; then test again.
An algorithm must have: clear input and output, finite steps (it must stop), precise (unambiguous) steps, and it must give the correct result.
Flowcharts
A flowchart is a picture of an algorithm using standard symbols joined by arrows.
- Oval (terminal): Start / Stop.
- Parallelogram: Input / Output.
- Rectangle: Process (a calculation or assignment).
- Diamond: Decision; one way in, two ways out (Yes/No).
- Arrow: direction of flow.
Flowcharts are easy to understand visually, but become large for big problems.
Pseudocode
Pseudocode writes an algorithm in simple English-like statements with keywords like INPUT, COMPUTE, PRINT, IF…ELSE, WHILE. It is not a real language, so it ignores exact syntax.
INPUT A, B
IF A > B THEN
PRINT A
ELSE
PRINT BAlgorithms can have sequence (steps one after another), selection (IF decisions) and repetition (loops).
Decomposition
Decomposition means breaking a complex problem into smaller, simpler sub-problems. Each part is solved (often by a different person or function) and then combined.
Example: a railway reservation system decomposes into: search trains, check seats, book ticket, take payment, print ticket.
Benefits: easier to understand, work can be shared, errors are easier to find, parts can be reused.
Board exam focus
Expect: draw a flowchart or write pseudocode for simple tasks (larger of numbers, sum of first n numbers, even/odd, grade from marks), name symbols, list the steps of problem solving, and explain decomposition with an example.
Key formulas and definitions
- Problem solving: Analyse → Algorithm → Code → Test → Debug
- Algorithm = finite, precise, ordered steps with input and output
- Oval = start/stop; Parallelogram = I/O; Rectangle = process; Diamond = decision
- Building blocks: sequence, selection, repetition
Worked examples
1. Write an algorithm to find the area of a rectangle.
1. Start. 2. Input length L and breadth B. 3. Area = L × B. 4. Print Area. 5. Stop.
2. Write pseudocode to check if a number is even or odd.
INPUT N IF N MOD 2 = 0 THEN PRINT "Even" ELSE PRINT "Odd"
3. Describe a flowchart to print the sum of numbers from 1 to 10.
Start → process: sum = 0, i = 1 → decision: i <= 10? → Yes: process sum = sum + i, i = i + 1, arrow back to the decision → No: output sum → Stop.
4. Decompose 'run a school sports day'.
Sub-problems: list events, register students, arrange ground and equipment, schedule, judge and record results, give prizes. Each can be handled by a team and joined.
5. Trace the larger-number flowchart for A = 5, B = 12.
Start → input A = 5, B = 12 → is 5 > 12? No → print B = 12 → Stop.
6. Write pseudocode to print the grade: marks ≥ 90 → A, ≥ 75 → B, else C.
INPUT M IF M >= 90 THEN PRINT "A" ELSE IF M >= 75 THEN PRINT "B" ELSE PRINT "C"
Common mistakes
- Using a rectangle for a decision. Decisions always use a diamond with Yes/No exits.
- Writing an algorithm that never stops. An algorithm must be finite.
- Skipping testing with unusual inputs like 0 or negative numbers.
- Mixing up input/output (parallelogram) with process (rectangle).