NCERT Solutions Class 9 Maths Chapter 11: The World of Algorithms | Notes Bazar Skip to content
Handwritten CBSE notes · instant PDF download after payment +91 88240 98091
Home › NCERT Solutions › Class 9 Maths › Chapter 11
NCERT Solutions · Class 9 Maths · Ganita Manjari Part II · Chapter 11

Chapter 11: The World of Algorithms (Algorithms)

Step-by-step solutions to Exercise Sets 11.1 to 11.3 and all End-of-Chapter Exercises of Ganita Manjari Part II Chapter 11 (NCERT Class 9 Maths, 2026-27): the addition algorithm, algorithms for divisors and gcd, Euclid's and Āryabhaṭa's methods, prime-testing and prime factorisation. All 15 questions are answered, with the key answer highlighted.

An algorithm is a precise, step-by-step procedure. When we write one we must (1) make every step exact, (2) check that it handles every case, (3) justify that the answer is correct, and (4) think about how much work it takes.

Exercise Set 11.1

1
Add two 4-digit numbers using the steps we have written down. Make sure you follow the steps precisely; do not perform any action that is not explicitly mentioned. Are you able to obtain the correct result?
Solution

Example: 4786 + 3597. Following the steps exactly:

  • Step 1: write 4786 above 3597, digits aligned from the right.
  • Step 2: rightmost digits 6 + 7 = 13 (more than 10): write 3, carry = 1.
  • Step 3: next column 8 + 9 + 1 = 18: write 8, carry = 1.
  • Step 4 (repeat Step 3): 7 + 5 + 1 = 13: write 3, carry = 1; then 4 + 3 + 1 = 8: write 8, carry = 0.
  • Step 5: carry is 0, so nothing more is written.

Result: 8383, which is correct (4786 + 3597 = 8383).

But try 4785 + 3125: in Step 2 the sum is 5 + 5 = 10. The steps say what to do if the sum is "less than 10" or "more than 10", but not if it is exactly 10! Followed precisely, the algorithm gets stuck. The fix is to change "more than 10" to "10 or more" in Steps 2 and 3 (as the text itself said before the algorithm). With that change, 4785 + 3125 = 7910 ✓.

For most numbers the steps give the correct sum (e.g. 4786 + 3597 = 8383), but a column sum of exactly 10 is not covered; "more than 10" must be changed to "10 or more".

2
What happens if you add a 5-digit number to a 3-digit number? Do our steps handle this situation correctly?
Solution

Take 45678 + 396. After three columns, the 3-digit number has no more digits, but Step 3 says "add the two digits and the current value of carry". There is only one digit, so the steps do not say what to do, and Step 4 ("until there are no more digits on the left") is also unclear.

To handle it, we must add an instruction: "if one number has no digit in a column, treat that digit as 0" (or write extra zeros in front of the shorter number: 00396). Then:

Not exactly: the steps assume both numbers have a digit in every column. Treating missing digits as 0 (writing 396 as 00396) fixes this; e.g. 45678 + 396 = 46074.

3
Why is it important to align the columns from right to left?
Solution

In the place-value system, the rightmost digit is units, the next is tens, then hundreds, and so on. Aligning from the right puts units under units, tens under tens, etc., so each column adds quantities of the same place value. If we aligned from the left, numbers of different lengths would add, for example, hundreds to tens: 473 + 69 would be added as 473 + 690, giving 1163 instead of the correct 542.

So that digits of the same place value (units with units, tens with tens, ...) are added together.

4
In Step 3, why cannot the value of carry be more than 1?
Solution

The largest digits are 9. In the first column the largest sum is 9 + 9 = 18, so the carry is at most 1. In any later column the largest sum is 9 + 9 + 1 = 19, which is still less than 20, so the carry is again at most 1. This continues for every column.

The largest possible column sum is 9 + 9 + 1 = 19 < 20, so the carry is never more than 1.

5
What happens if we do not include the fifth step in the algorithm above? Give examples where the algorithm will work correctly and where it will fail to work.
Solution

Step 5 writes the final carry. Without it, a carry out of the leftmost column is lost.

  • Works: 23 + 45. The last column gives 2 + 4 = 6 with carry 0, so the result 68 is correct.
  • Fails: 73 + 45. The last column gives 7 + 4 = 11: we write 1 and carry 1, but without Step 5 the carry is never written. The result would be 18 instead of 118.

Without Step 5 the answer is wrong whenever the leftmost column produces a carry (73 + 45 would give 18 instead of 118); it is correct only when the final carry is 0 (e.g. 23 + 45 = 68).

Exercise Set 11.2

1
Suppose List 1 and List 2 are two lists of numbers in increasing order. (i) Write an algorithm to find elements in List 1 that are not present in List 2. (ii) Write an algorithm to find elements in List 2 that are not present in List 1.
Solution

(i) Algorithm only-in-list-1:

  1. Start with an empty list result.
  2. For each number x in List 1:
    • if x does not appear in List 2, add x to the end of result.
  3. Report result.

Because both lists are in increasing order, result is also in increasing order. A faster version uses the ordering: keep a position in each list, start both at the first element, and repeatedly compare the current elements a (List 1) and b (List 2): if a < b, a is not in List 2, so add it to result and move on in List 1; if a = b, move on in both lists; if a > b, move on in List 2. When List 2 runs out, add all remaining elements of List 1. This scans each list only once.

Example: List 1 = [1, 3, 5, 15, 25, 75, 125, 375], List 2 = [1, 3, 5, 11, 15, 25, 33, 55, 75, 165, 275, 825] gives result = [125, 375].

(ii) Exchange the roles of the two lists: for each number y in List 2, add y to result if it does not appear in List 1. For the example above, result = [11, 33, 55, 165, 275, 825].

For each element of one list, add it to the answer if it is not in the other list (or use a single simultaneous scan of both sorted lists).

2
Describe an algorithm to compute the least common multiple (lcm) of two numbers.
Solution

Method 1 (from the definition): the lcm is the smallest number that is a multiple of both m and n.

  1. Let big be the larger of m and n, and small the smaller.
  2. For each k = 1, 2, 3, ...:
    • if k × big is divisible by small, report k × big as lcm(m, n) and stop.

This always stops, at the latest when k = small (since big × small is a multiple of both). Example: lcm(6, 15): 15 (not divisible by 6), 30 (divisible), so lcm = 30.

Method 2 (using gcd): compute gcd(m, n) with Euclid's algorithm, then

Example: .

Check the multiples of the larger number in order until one is divisible by the smaller number; or use lcm(m, n) = m × n ÷ gcd(m, n).

3
Divisors occur in pairs. For instance, the divisors of 18 are (1, 18), (2, 9) and (3, 6). (i) If we write out divisors in pairs, how many numbers do we have to examine between 1 and n to find all the divisors of n? (ii) If we list out the divisors in pairs, will our gcd algorithm still work in the manner we have described?
Solution

(i) In each pair (j, n/j), the smaller number j satisfies , i.e. . So we only need to examine j = 1, 2, ..., up to ; each time j divides n we get two divisors, j and n/j. For n = 18 we check only 1, 2, 3, 4 (since ). For n = 10000 we check only 100 numbers instead of 10000.

(ii) Not without a change. Listed in pairs, the divisors are not in increasing order: for 18 we would get [1, 18, 2, 9, 3, 6]. Our algorithm reported the rightmost common divisor as the gcd, which relied on the list being in increasing order. With pairs, the rightmost common divisor need not be the largest one. We must either sort the lists first or look for the largest common divisor rather than the rightmost one.

(i) Only the numbers from 1 to √n. (ii) No: the lists are no longer in increasing order, so "take the rightmost common divisor" must be replaced by "take the largest common divisor".

Exercise Set 11.3

1
How would our original algorithm change if we computed the divisors of n by examining the numbers from 1 to n in reverse order, from n down to 1?
Solution

The lists of divisors would come out in decreasing order (e.g. divisors(18) = [18, 9, 6, 3, 2, 1]), and so would the list of common divisors. The largest common divisor would then be the first (leftmost) element instead of the last. So the only change is in the last step: report the leftmost element of common-divisors as gcd(m, n).

Everything works the same, but the lists are in decreasing order, so the gcd is the leftmost element of the list of common divisors.

2
What about the last algorithm described above? What happens when we look at common divisors starting from min(m, n) and work backwards to 1?
Solution

Scanning k = min(m, n), min(m, n) − 1, ..., 1, the first k that divides both m and n is the largest common divisor, i.e. the gcd. So we can stop as soon as we find it, without keeping most-recent-common-divisor or checking the remaining numbers. (In the worst case, when the gcd is 1, we still check all the numbers.)

Example: gcd(6, 12): start at 6, which divides both, so the answer is 6 after just one check.

The first common divisor found is the gcd, so we can stop immediately; this is usually faster.

End-of-Chapter Exercises

1
Compute the following using the improved version of Euclid's algorithm. (i) gcd(375, 825) (ii) gcd(51000, 81000) (iii) gcd(1789287, 237656) (iv) gcd(2587392, 157656)
Solution

Each step replaces gcd(m, n) by gcd(n, m mod n), until the remainder is 0.

(i) gcd(825, 375): ; . So gcd = 75.

(ii) gcd(81000, 51000):

So gcd = 3000.

(iii) gcd(1789287, 237656):

So gcd = 1: the two numbers have no common factor other than 1.

(iv) gcd(2587392, 157656):

So gcd = 24.

(i) 75 (ii) 3000 (iii) 1 (iv) 24

2
Assume that m ≥ n. Verify that d divides m and n if and only if d divides both n and m mod n.
Solution

Divide m by n: , where q is the quotient and ().

  • If d divides m and n, say and , then , so d divides r.
  • If d divides n and r, say and , then , so d divides m.

So m, n and n, m mod n have exactly the same common divisors, and therefore the same gcd. This is why Āryabhaṭa's division step is correct.

Writing m = qn + r: a common divisor of m and n divides r = m − qn, and a common divisor of n and r divides m = qn + r.

3
Write an algorithm prime(n) to check if n is prime. (Hint: A prime number p has exactly two distinct factors, 1 and p. Can you make use of divisors(n) to write out prime(n)?)
Solution

Algorithm prime(n):

  1. Compute the list divisors(n).
  2. If the list has exactly two elements, report "n is prime".
  3. Otherwise, report "n is not prime".

This handles n = 1 correctly too: divisors(1) = [1] has only one element, and 1 is not prime.

Faster version: n (> 1) is prime if no j with divides n, because if n = ab with , then . Example: to test 97 we only check 2, 3, 4, ..., 9; none divides 97, so 97 is prime.

prime(n): compute divisors(n); n is prime exactly when this list has exactly two elements (1 and n).

4
Write an algorithm primedivisors(n) to compute the list of divisors of n that are prime numbers. (Hint: Compute divisors(n) and then filter out the primes in this list.)
Solution

Algorithm primedivisors(n):

  1. Compute the list divisors(n).
  2. Start with an empty list prime-divisors.
  3. For each d in divisors(n):
    • if prime(d) reports that d is prime, add d to the end of prime-divisors.
  4. Report prime-divisors.

Example: divisors(180) = [1, 2, 3, 4, 5, 6, 9, 10, 12, 15, 18, 20, 30, 36, 45, 60, 90, 180]; filtering the primes gives primedivisors(180) = [2, 3, 5].

Compute divisors(n), then keep only those divisors d for which prime(d) is true.

5
We can also find the gcd of two numbers by computing prime factorisation of both the numbers. Try to write an algorithm to compute the prime factorisation of a number. (i) The prime factorisation of 180 is . How would you represent this? (ii) How would you compare the prime factorisations of two numbers?
Solution

Algorithm factorise(n) (for n > 1):

  1. Start with an empty list factors, and let p = 2.
  2. While n > 1:
    • Count how many times p divides n: set e = 0; while p divides n, replace n by n ÷ p and increase e by 1.
    • If e > 0, add the pair (p, e) to the end of factors.
    • Increase p by 1.
  3. Report factors.

Only primes are ever recorded, because by the time p is reached, all smaller primes have already been divided out (so a composite p, like 4 or 6, can no longer divide n).

(i) Represent the factorisation as a list of (prime, exponent) pairs in increasing order of the primes:

(ii) To compare two factorisations, go through the primes. For the gcd, take each prime that appears in both lists with the smaller of its two exponents; for the lcm, take every prime with the larger exponent. Example:

Divide out 2, 3, 4, ... in turn, recording each prime with its exponent; 180 → [(2, 2), (3, 2), (5, 1)]. For the gcd take common primes with the smaller exponents (for the lcm, the larger exponents).

← Chapter 10: How Quantities Combine: Understanding Data Chapter 12: Quadrilaterals →
Preparing for Class 9 exams?

Get our complete, exam-ready Class 9 notes. Instant PDF download.

Found a mistake or need help with a question? Message us on WhatsApp.