Chapter 7 — Introduction to Problem Solving

Easy-language Notes · Part 1 of 2 (problem solving · algorithm · flowcharts)
REVISION NOTES
Class XI · Computer Science (083)
Sheet 1 (Front)

1. What is Problem Solving?

Problem solving is finding an organised way to move from a problem statement to a working solution. In computer science, the final solution is usually a program, but the thinking work happens before any code is written.

It is the same approach you use in daily life. Want to bake a cake? You read the recipe, gather ingredients, mix in order, bake, and then taste. The same five-stage thinking applies to writing programs.

Why a structured approach?

  • Big problems are easier to solve in small parts.
  • A clear plan makes coding faster and shorter.
  • Mistakes are caught early — before they become hard bugs.
  • Other people (and future-you) can read and reuse the plan.

Where this chapter fits

Before learning Python syntax, we learn the thinking tools a programmer uses every day: algorithms, flowcharts, pseudocode, and decomposition. These tools work for any language, not just Python.

Don't jump to the keyboard. The best programmers spend more time thinking than typing. A clear plan on paper saves hours of debugging on the screen.

2. The Five Steps of Problem Solving

Every programming task moves through these five stages, in order. Skipping any one of them usually leads to bugs or wasted work.

StepWhat you do
1. AnalyseUnderstand the problem — what are the inputs, outputs, and rules?
2. AlgorithmWrite a step-by-step plan in plain language.
3. CodingTranslate the algorithm into a programming language.
4. TestingRun the program with sample inputs and check the output.
5. DebuggingIf the output is wrong, find the cause and fix it.
Problem: "Find the average of three numbers."
  • Analyse → inputs: 3 numbers; output: their mean.
  • Algorithm → read 3 numbers, add, divide by 3, print.
  • Coding → write Python statements.
  • Testing → try (10, 20, 30) → expect 20.
  • Debugging → if it prints 60, the divide step is missing.
Testing finds the symptom (wrong output). Debugging finds the cause (the buggy line) and removes it. The two are different jobs even though they happen close together.

3. What is an Algorithm?

An algorithm is a finite sequence of well-defined steps that solves a problem. It must finish, must produce a result, and must work for every valid input.

An algorithm is just a clear recipe written in your own language. Each line tells the computer (or a person) exactly what to do next, with no room for guessing.

Characteristics of a Good Algorithm

PropertyMeaning
FinitenessEnds after a limited number of steps.
DefinitenessEach step is clear and unambiguous.
InputTakes zero or more well-defined inputs.
OutputProduces at least one output.
EffectivenessEach step can actually be carried out.
Algorithm to find the larger of two numbers:
  1. Start.
  2. Read two numbers A and B.
  3. If A > B, print A; else print B.
  4. Stop.
Four steps, finite, definite, has input and output — meets every characteristic.
An algorithm is language-free. The same algorithm can later be coded in Python, C++, or Java — the steps stay the same, only the syntax changes.

4. Flowcharts

A flowchart is a picture of an algorithm drawn with standard shapes connected by arrows. The shape tells you the kind of step, and the arrow tells you the order.

Standard Symbols

ShapeUsed for
Oval (terminator)Start / Stop of the flow
ParallelogramInput or Output (READ / PRINT)
RectangleProcess (calculation, assignment)
DiamondDecision (Yes/No question)
ArrowDirection of the flow
Flowchart for "Read two numbers and print their sum":
+--------+   +-----------+   +-----------+   +---------+   +-------+
| Start  |->| Read A, B |->| C = A + B |->| Print C |->| Stop  |
+--------+   +-----------+   +-----------+   +---------+   +-------+
Three rectangles + two ovals + arrows. No decision is needed because the flow is purely sequential.
Flowchart with a decision — "Pass / Fail":
  Start -> Read m -> < m >= 33? >
                       /        \
                    Yes          No
                     v            v
                Print "Pass"  Print "Fail"
                     \           /
                      \         /
                       v       v
                         Stop
The diamond < m >= 33? > branches the flow into two paths. Both paths meet again at the Stop oval.
A diamond always has two arrows leaving it — one labelled Yes (or True) and one labelled No (or False). Forgetting one of the labels is a common mistake.

Reading a Flowchart

  1. Start at the oval labelled "Start".
  2. Follow each arrow in order.
  3. At a diamond, pick the path matching the answer.
  4. Stop when you reach the closing oval.

Chapter 7 — Introduction to Problem Solving

Easy-language Notes · Part 2 of 2 (pseudocode · decomposition)
REVISION NOTES
Class XI · Computer Science (083)
Sheet 1 (Back)

5. Pseudocode

Pseudocode is an algorithm written in plain English with a few programming-style words. It is not a real language — the computer cannot run it — but it sits between the algorithm and the actual code.

Common Conventions

  • BEGIN / END mark the start and end.
  • READ x means take input. PRINT x means show output.
  • SET x = value or x ← value means assignment.
  • IF … THEN … ELSE … ENDIF for decisions.
  • WHILE … DO … ENDWHILE or FOR … ENDFOR for loops.
  • Indent the body of every IF, WHILE, and FOR.
Pseudocode for "Average of three numbers":
BEGIN
    READ a, b, c
    SET avg = (a + b + c) / 3
    PRINT avg
END
Five lines — one start, one input, one process, one output, one stop.
Pseudocode with a decision — "Pass / Fail":
BEGIN
    READ marks
    IF marks >= 33 THEN
        PRINT "Pass"
    ELSE
        PRINT "Fail"
    ENDIF
END
Indentation under IF / ELSE makes the two branches obvious to the reader.
Pseudocode with a loop — sum 1 to N:
BEGIN
    READ n
    SET total = 0
    FOR i = 1 TO n DO
        total = total + i
    ENDFOR
    PRINT total
END

Flowchart vs Pseudocode

FlowchartPseudocode
Picture — visualText — closer to code
Best for short logicBest for long algorithms
Easy for non-codersEasy to translate to a real language
Hard to edit on paperEasy to edit / version-control

Common Pseudocode Mistakes

  • Missing END (or ENDIF / ENDWHILE / ENDFOR) at the close of a block.
  • Putting a condition on ELSE — ELSE never has a condition.
  • Forgetting to indent the body of an IF or loop — readers cannot tell where the block ends.
  • Mixing English and code — "if marks is good print Pass" is too vague to translate.
Pseudocode keywords are written in UPPERCASE by convention. This makes structure words like IF, WHILE, BEGIN stand out from data names like marks or total.

6. Decomposition

Decomposition means splitting a big problem into smaller sub-problems. Each sub-problem is easier to plan, code, and test than the whole.

It is the same trick you use to clean a room — you don't tackle "the whole room" in one go. You clean the bed, then the table, then the floor. Each part is small enough to actually finish.
Big problem: "Print a student's report card."
  • Sub-problem A — read marks of all subjects.
  • Sub-problem B — calculate the total.
  • Sub-problem C — calculate the percentage.
  • Sub-problem D — decide the grade from percentage.
  • Sub-problem E — print the report card neatly.
Five small jobs are easier than one big one. Each can be tested on its own.
Big problem: "Build a basic calculator."
  • Sub-problem 1 — read the two numbers.
  • Sub-problem 2 — read the operator (+, −, ×, ÷).
  • Sub-problem 3 — perform the matching operation.
  • Sub-problem 4 — print the result (and handle divide-by-zero).
Each sub-problem can be tested independently before they are joined.

Benefits

  • Easier to understand — each part has a single job.
  • Easier to debug — bugs stay inside one part.
  • Reusable — a sub-program for "average" can be used again later.
  • Team-friendly — different people can write different parts.
  • Faster to test — small parts give clear pass / fail signals.

How small should a sub-problem be?

A useful rule is the "one sentence" test: if you can describe what a sub-problem does in one short sentence, it is small enough. If you need "and… and… and…", split it again.

Description (one sentence)Verdict
"Calculate the percentage."Good size
"Read marks, find total, find %, decide grade, print."Too big — split
"Print a header line."Good size
A good size for a sub-problem is one that fits in your head all at once. If a function or block is more than 15–20 lines, it is probably doing too much — decompose it again.
Decomposition is not a one-time step. As you grow a program, you will keep re-decomposing — splitting a function that has become too big, or merging two that have become too small.

Chapter 7 Worksheet — Introduction to Problem Solving

Total: 50 marks  |  Time: 75 min
Name: Class/Sec: Roll No.: Date:

Section A — Multiple Choice (1 × 10 = 10)

  1. Which is NOT one of the five steps of problem solving?
    (a) Coding(b) Testing(c) Debugging(d) Marketing
  2. The flowchart symbol used for input / output is a:
    (a) Rectangle(b) Parallelogram(c) Diamond(d) Oval
  3. Which characteristic says an algorithm must end?
    (a) Definiteness(b) Effectiveness(c) Finiteness(d) Output
  4. A diamond shape in a flowchart represents:
    (a) Process(b) Start / Stop(c) Decision(d) Input
  5. Pseudocode is best described as:
    (a) A real language(b) A picture-based plan(c) English-like steps(d) Machine code
  6. Splitting a big problem into smaller sub-problems is called:
    (a) Compilation(b) Decomposition(c) Translation(d) Iteration
  7. "Each step must be clear and unambiguous" describes:
    (a) Definiteness(b) Finiteness(c) Input(d) Output
  8. Finding and fixing a bug is called:
    (a) Testing(b) Debugging(c) Coding(d) Compiling
  9. Which keyword pair commonly marks start and end of pseudocode?
    (a) IF / ENDIF(b) BEGIN / END(c) READ / PRINT(d) DO / WHILE
  10. An arrow in a flowchart shows:
    (a) A process(b) An output(c) Direction of flow(d) A decision

Section B — Trace the Pseudocode (1 × 8 = 8)

  1. SET a = 6, b = 9
    PRINT a + b
    Output:
  2. SET x = 10
    IF x > 0 THEN
      PRINT "+ve"
    ELSE
      PRINT "-ve"
    ENDIF
    Output:
  3. FOR i = 1 TO 3 DO
      PRINT i * 10
    ENDFOR
    Output:
  4. SET total = 0
    FOR i = 1 TO 4 DO
      total = total + i
    ENDFOR
    PRINT total
    Output:
  5. SET marks = 75
    IF marks >= 33 THEN
      PRINT "Pass"
    ELSE
      PRINT "Fail"
    ENDIF
    Output:
  6. SET a = 5, b = 12
    IF a > b THEN PRINT a
    ELSE PRINT b
    ENDIF
    Output:
  7. SET n = 4
    WHILE n > 0 DO
      PRINT n
      n = n - 1
    ENDWHILE
    Output:
  8. SET p = 2, count = 0
    WHILE p < 30 DO
      p = p * 2
      count = count + 1
    ENDWHILE
    PRINT count
    Output:

Section C — Find the Error (1 × 6 = 6)

Each pseudocode has exactly one error. Mark the line number and write the correction.

  1. 1  BEGIN
    2    SET total = a + b
    3    PRINT total
    4  END
    Wrong line:   Correction:
  2. 1  BEGIN
    2    READ x
    3    IF x > 0 THEN
    4      PRINT "+ve"
    5  END
    Wrong line:   Correction:
  3. 1  BEGIN
    2    READ a, b
    3    IF a > b
    4      PRINT a
    5    ENDIF
    6  END
    Wrong line:   Correction:
  4. 1  BEGIN
    2    SET n = 5
    3    WHILE n > 0 DO
    4      PRINT n
    5    ENDWHILE
    6  END
    Wrong line:   Correction:
  5. 1  BEGIN
    2    READ marks
    3    IF marks >= 33 THEN
    4      PRINT "Pass"
    5    ELSE marks < 33
    6      PRINT "Fail"
    7    ENDIF
    8  END
    Wrong line:   Correction:
  6. 1  BEGIN
    2    SET sum = 0
    3    FOR i = 1 TO 5
    4      sum = sum + i
    5    ENDFOR
    6    PRINT sum
    7  END
    Wrong line:   Correction:

Section D — Short Answer (2 × 5 = 10)

  1. List the five steps of problem solving in order, with one sentence each.
  2. Define an algorithm. List any two of its characteristics.

Chapter 7 Worksheet — (continued)

Sheet 2 (Back)

Section D — Short Answer (continued) (2 × 5 = 10)

  1. Differentiate between a flowchart and pseudocode — give one point each.
  2. Why is decomposition useful in problem solving? State any two benefits.
  3. What is the difference between testing and debugging?

Section E — Algorithm / Flowchart Tasks (16 marks)

Use a separate sheet for flowchart drawings if you need more space. Pseudocode answers may use BEGIN/END, READ, PRINT, IF/ELSE, WHILE/FOR.

  1. (3) Write an algorithm (numbered steps) to find the largest of three numbers entered by the user.
  2. (3) Write pseudocode to read a number and print whether it is even or odd. Use IF / ELSE.
  3. (3) Draw a flowchart for "Read principal P, rate R, time T — compute Simple Interest = (P×R×T)/100 — print result". Label every shape.
  4. (4) A school report card needs: total, percentage, and grade. Show the decomposition — list the sub-problems and write a one-line role for each.
  5. (3) Write pseudocode to print the numbers from 1 to N, where N is read from the user. Use a FOR loop.