Study Hamlet

Class 9 Maths · Chapter 11: The World of Algorithms

25 questions with worked answers. Try to answer each one in your head, then tap it to check. Add the chapter to your free revision queue and Study Hamlet brings each card back just before you would forget it.

+ Add to my revision (free)
  1. Which of the following shapes is standard for representing a "Decision" block in a flowchart? (a) Rectangle (b) Oval (c) Diamond (d) Parallelogram

    Answer

    (c) Diamond

  2. What is the output of Euclid's algorithm when computing GCD(48, 18)? (a) 2 (b) 3 (c) 6 (d) 12

    Answer

    (c) 6 [48 = 182 + 12; 18 = 121 + 6; 12 = 6*2 + 0 => GCD = 6]

  3. What is the main characteristic of an algorithm? (a) Infinite execution time (b) Well-defined, step-by-step instructions with a clear termination condition (c) Written exclusively in Python code (d) Always involves random numbers

    Answer

    (b) Well-defined, step-by-step instructions with a clear termination condition

  4. In a searching algorithm, Linear Search has a worst-case time complexity of scanning how many elements for a list of size n? (a) 1 (b) n / 2 (c) n (d) n^2

    Answer

    (c) n

  5. What loop control condition prevents an infinite loop? (a) A condition that always evaluates to True (b) A condition that eventually evaluates to False (c) Removing all variables from the loop (d) Increasing loop count endlessly

    Answer

    (b) A condition that eventually evaluates to False

  6. Which symbol is used for Input/Output operations in standard flowcharts? (a) Oval (b) Parallelogram (c) Rectangle (d) Circle

    Answer

    (b) Parallelogram

  7. When checking whether a positive integer N is prime, it is sufficient to test divisibility by integers up to: (a) N / 2 (b) N - 1 (c) Square Root of N (sqrt(N)) (d) N^2

    Answer

    (c) Square Root of N (sqrt(N))

  8. What does a rectangle shape represent in a standard algorithm flowchart? (a) Start/Stop (b) Process / Computation (c) Decision (d) Connector

    Answer

    (b) Process / Computation

  9. Fill in the blank: A step-by-step procedure to solve a specific mathematical or computational problem is called an ____________.

    Answer

    Algorithm

  10. Fill in the blank: Repetition of a block of instructions in an algorithm is called a loop or ____________.

    Answer

    Iteration

  11. Fill in the blank: Euclid's algorithm computes the Greatest Common Divisor of two integers a and b by repeatedly taking the ____________ of a divided by b.

    Answer

    Remainder

  12. Fill in the blank: Sorting an array by repeatedly swapping adjacent out-of-order elements is known as ____________ Sort.

    Answer

    Bubble

  13. True or False: Binary search can be performed on an unsorted list.

    Answer

    False [Binary search requires the list to be sorted]

  14. True or False: An algorithm must terminate after a finite number of steps.

    Answer

    True

  15. Assertion (A): To check if 101 is prime, we only need to test prime divisors up to 10 (2, 3, 5, 7). Reason (R): If a number N has a factor greater than sqrt(N), it must also have a corresponding factor less than or equal to sqrt(N). (a) Both A and R are true and R is the correct explanation of A. (b) Both A and R are true but R is NOT the correct explanation of A. (c) A is true but R is false. (d) A is false but R is true.

    Answer

    (a) Both A and R are true and R is the correct explanation of A.

  16. Write down the step-by-step pseudo-code algorithm to find the largest of three given numbers A, B, and C.

    Answer

    Algorithm: Find Max of A, B, C Step 1: Input three numbers A, B, C. Step 2: If A >= B and A >= C, then Max = A. Step 3: Else if B >= A and B >= C, then Max = B. Step 4: Else Max = C. Step 5: Output Max. Step 6: Stop.

  17. Trace Euclid's division algorithm step-by-step to compute the GCD of 252 and 105.

    Answer

    Euclid's Algorithm for GCD(252, 105): Step 1: Divide 252 by 105. 252 = 105 * 2 + 42 (Remainder r = 42) Step 2: Divide 105 by 42. 105 = 42 * 2 + 21 (Remainder r = 21) Step 3: Divide 42 by 21. 42 = 21 * 2 + 0 (Remainder r = 0) Step 4: Remainder is 0. The divisor at this stage is 21. Therefore, GCD(252, 105) = 21.

  18. Draw a textual flowchart description (using step boxes) to determine if a given year Y is a leap year.

    Answer

    Leap Year Algorithm Flowchart Steps: [START] -> Input Year Y | [DECISION: Is Y divisible by 400?] --> YES: [Output: Leap Year] -> [STOP] --> NO: | [DECISION: Is Y divisible by 100?] --> YES: [Output: Not a Leap Year] -> [STOP] --> NO: | [DECISION: Is Y divisible by 4?] --> YES: [Output: Leap Year] -> [STOP] --> NO: [Output: Not a Leap Year] -> [STOP]

  19. Explain the logic of checking whether a given number N is prime using an algorithmic step-by-step breakdown.

    Answer

    Algorithm: Prime Check for N (N > 1) Step 1: Input integer N. Step 2: If N <= 1, print "Not Prime" and Stop. Step 3: Set i = 2. Step 4: While i * i <= N: a. If N % i == 0, print "Not Prime" and Stop. b. Set i = i + 1. Step 5: Print "Prime" and Stop.

  20. Given the array [5, 2, 8, 1, 4], show the step-by-step state of the array after each pass using Bubble Sort (ascending order).

    Answer

    Initial Array: [5, 2, 8, 1, 4] Pass 1: Compare 5 and 2 -> Swap -> [2, 5, 8, 1, 4] Compare 5 and 8 -> No swap -> [2, 5, 8, 1, 4] Compare 8 and 1 -> Swap -> [2, 5, 1, 8, 4] Compare 8 and 4 -> Swap -> [2, 5, 1, 4, 8] (8 is sorted) Pass 2: Compare 2 and 5 -> No swap -> [2, 5, 1, 4, 8] Compare 5 and 1 -> Swap -> [2, 1, 5, 4, 8] Compare 5 and 4 -> Swap -> [2, 1, 4, 5, 8] (5 is sorted) Pass 3: Compare 2 and 1 -> Swap -> [1, 2, 4, 5, 8] Compare 2 and 4 -> No swap -> [1, 2, 4, 5, 8] Pass 4: No swaps needed. Array is completely sorted: [1, 2, 4, 5, 8].

  21. Explain the key difference between Linear Search and Binary Search in terms of prerequisites and efficiency.

    Answer

    Prerequisite: Linear Search works on both sorted and unsorted lists. Binary Search strictly requires the data list to be sorted. Efficiency: Linear search checks elements sequentially (takes up to n comparisons for n items). Binary search repeatedly divides the search interval in half (takes up to log2(n) comparisons), making it exponentially faster for large datasets.

  22. Trace the following algorithmic loop and give the final value of S: Step 1: Set S = 0, i = 1 Step 2: If i > 5, jump to Step 6 Step 3: Set S = S + i * i Step 4: Set i = i + 1 Step 5: Jump to Step 2 Step 6: Print S.

    Answer

    Tracing the loop: Initial: S = 0, i = 1 Iteration 1: i=1 <= 5 -> S = 0 + 1^2 = 1, i becomes 2 Iteration 2: i=2 <= 5 -> S = 1 + 2^2 = 5, i becomes 3 Iteration 3: i=3 <= 5 -> S = 5 + 3^2 = 14, i becomes 4 Iteration 4: i=4 <= 5 -> S = 14 + 4^2 = 30, i becomes 5 Iteration 5: i=5 <= 5 -> S = 30 + 5^2 = 55, i becomes 6 Iteration 6: i=6 > 5 -> Jump to Step 6. Final output S = 55. (This calculates sum of squares 1^2+2^2+3^2+4^2+5^2).

  23. Write an algorithm using modulo arithmetic to find the Least Common Multiple (LCM) of two numbers a and b, given the relationship LCM(a, b) = (a * b) / GCD(a, b).

    Answer

    Algorithm LCM(a, b): Step 1: Input two positive integers a and b. Step 2: Store original values: x = a, y = b. Step 3: Compute GCD(x, y) using Euclid's algorithm: While y != 0: temp = y y = x % y x = temp gcd_val = x Step 4: Compute LCM = (a * b) / gcd_val. Step 5: Output LCM.

  24. Construct an algorithm to compute the factorial of a positive integer N (N!).

    Answer

    Algorithm Factorial(N): Step 1: Input non-negative integer N. Step 2: Set fact = 1, i = 1. Step 3: If N == 0 or N == 1, go to Step 6. Step 4: While i <= N: fact = fact * i i = i + 1 Step 5: Output fact. Step 6: Stop.

  25. Identify the error in the following algorithm designed to count down from 10 to 1: Step 1: Set count = 10 Step 2: Print count Step 3: Set count = count + 1 Step 4: If count > 0 go to Step 2.

    Answer

    Errors in the countdown algorithm: Step 3 increments count (count = count + 1) instead of decrementing (count = count - 1). The condition in Step 4 (count > 0) will remain perpetually True (10, 11, 12, ...), creating an infinite loop. Correction: Change Step 3 to Set count = count - 1.

← Chapter 10: How Quantities Combine: Understanding Data→ Chapter 12: Quadrilaterals

More Class 9 Maths chapters