Class 9 Maths Chapter 11: The World of Algorithms | Notes & Questions
Introduction: What is an algorithm?
An algorithm is a finite, ordered set of clear instructions used to solve a problem or complete a task. We use algorithms in mathematics, computers and everyday life. A recipe, a method for finding the largest number, and a procedure for calculating the area of a rectangle can all be described as algorithms. The important idea is that each step should be understandable and the complete procedure should lead to the required result.
1. Main features of a good algorithm
- Clear: Every instruction has one understandable meaning.
- Ordered: Steps are arranged in the correct sequence.
- Finite: The process finishes after a limited number of steps.
- Input and output: It accepts required information and produces a result.
- Effective: Each step can actually be carried out.
An instruction such as “choose a suitable number” may be unclear unless the selection rule is explained. A better instruction is “enter a positive whole number”. Precision makes an algorithm easier to follow and test.
2. Inputs, processing and outputs
Many algorithms can be understood through three stages. First, the user supplies input. Next, the algorithm processes that input using calculations or decisions. Finally, it displays or returns an output.
Example: Area of a rectangle
Input: length and breadth. Processing: multiply length by breadth. Output: area. The formula is Area = length × breadth. If length is 8 cm and breadth is 5 cm, the output is 40 cm². Notice that the unit is square centimetres because area measures a two-dimensional surface.
3. Writing an algorithm step by step
To write an algorithm, first understand the problem and identify what information is given and what must be found. Then arrange the operations in a logical order. Use numbered steps and simple language. Finally, test the procedure with sample values.
Example: Find the sum of two numbers
- Start.
- Read two numbers A and B.
- Calculate S = A + B.
- Display S.
- Stop.
If A = 14 and B = 9, the algorithm calculates S = 23. Trying another pair, such as 0 and 7, helps check that the method works for different inputs.
4. Decisions in an algorithm
Some problems require a decision. A decision checks a condition and follows one path if it is true and another if it is false. For example, to check whether a number is even, calculate the remainder when it is divided by 2. If the remainder is 0, display “Even”; otherwise, display “Odd”.
- Start.
- Input number N.
- Check whether N divided by 2 leaves remainder 0.
- If yes, display “Even”.
- If no, display “Odd”.
- Stop.
Testing with 12 should produce “Even”, while testing with 15 should produce “Odd”. Testing both branches is important.
5. Repetition and loops
A loop repeats a set of instructions. Repetition is useful when the same operation must be performed several times, such as adding the first ten natural numbers. A loop needs a clear stopping condition; otherwise, it may continue indefinitely.
Example: Add numbers from 1 to 5
- Set total = 0 and counter = 1.
- Add counter to total.
- Increase counter by 1.
- If counter is at most 5, repeat the addition step.
- Otherwise display total and stop.
The total becomes 1, then 3, 6, 10 and finally 15. The counter changes each time, so the stopping condition is eventually reached.
6. Flowcharts
A flowchart represents an algorithm using standard symbols and arrows. An oval commonly represents Start or Stop. A parallelogram represents input or output. A rectangle represents a processing step, and a diamond represents a decision. Arrows show the direction in which the procedure moves.
Flowcharts help readers see the order of operations and the branches created by decisions. Keep symbols neatly connected, label decision branches such as Yes and No, and make sure every path reaches an appropriate ending.
7. Tracing and testing an algorithm
Tracing means following the instructions one by one and recording how values change. A trace table can show the counter, current total and output at each step. Testing means trying different inputs to check whether the algorithm gives correct results.
For a number-checking algorithm, test a positive even number, an odd number, zero and, if allowed by the problem, a negative number. This helps reveal assumptions that may not have been considered. A single successful test does not prove that an algorithm works for every possible input.
8. Efficiency and choosing a method
Two algorithms may solve the same problem but use different numbers of steps. For small inputs, the difference may not matter. For large inputs, an efficient method can save time. For example, adding five values one by one is simple; adding thousands of values requires a systematic process that avoids unnecessary repeated work. At this level, focus on clarity, correctness and the number of steps.
Common mistakes
- Leaving out an input that the calculation needs.
- Writing instructions in an unclear order.
- Forgetting to update a counter in a loop.
- Creating a loop without a stopping condition.
- Testing only one input or only one decision branch.
- Confusing a processing symbol with a decision symbol in a flowchart.
Important questions and answers
Q1. Define an algorithm.
An algorithm is a finite sequence of clear steps for solving a problem.
Q2. What are input and output?
Input is the information supplied to a procedure; output is the result it produces.
Q3. Why must an algorithm be finite?
It must eventually stop and provide a result rather than continue forever.
Q4. Which flowchart symbol represents a decision?
A diamond.
Q5. What is tracing?
Tracing is following each instruction and recording how the values change.
Q6. Why should we test an algorithm with different inputs?
Different tests help identify errors and check how the procedure behaves in different cases.
Practice questions
- Write an algorithm to calculate the perimeter of a rectangle.
- Write the steps to decide whether a whole number is divisible by 5.
- What is the difference between a decision and a loop?
- Which flowchart symbol is used for input and output?
- Trace an algorithm that starts with total = 0 and adds 2, 4 and 6.
- Why is a stopping condition important in a loop?
Answers for self-check
- Input length and breadth; calculate P = 2 × (length + breadth); display P.
- Input N; check whether the remainder after division by 5 is zero; display the result.
- A decision selects a path; a loop repeats instructions.
- A parallelogram.
- The successive totals are 2, 6 and 12.
- It ensures that repetition ends and prevents an infinite loop.
Quick revision summary
- An algorithm is a clear, ordered and finite procedure.
- Identify inputs, processing steps and outputs.
- Use decisions when a condition affects the next step.
- Use loops for repeated operations and include a stopping condition.
- Flowcharts show the procedure visually.
- Trace and test algorithms with different inputs.
These original notes are for learning and practice. Follow the current NCERT/CBSE textbook and your teacher’s instructions for the exact syllabus.
