Skip to study material
← Question index

QUESTION 09 · Logic building

Give two benefits of writing an algorithm before coding.

2 marks

Answer

An algorithm helps plan and review a solution before dealing with programming syntax.

  • It separates the problem-solving steps from a particular language.
  • It makes missing cases or incorrect decisions easier to discuss and trace.

QUESTION 10 · Logic building

Explain the advantages and limitations of algorithms.

5 marks

Answer in brief

An algorithm helps us plan a solution step by step before writing a program. It has several advantages and some limitations.

Advantages of algorithms

  1. Easy to understand: The solution is written as simple, ordered steps. A student can follow one step at a time.
  2. Helps before coding: We can decide the inputs, calculations and output before writing C statements. This reduces confusion while coding.
  3. Independent of a programming language: The same solution can be implemented in C, Python or another language. The syntax changes, but the main steps can remain the same.
  4. Helps find mistakes: We can follow the steps with sample values and check the result. Missing steps and incorrect conditions can be found before coding.
  5. Makes coding easier: Once the steps are clear, each step can be converted into suitable program statements.

Limitations of algorithms

  1. Takes time to prepare: A detailed solution needs careful planning, especially for a large problem.
  2. Can become lengthy: A large problem may need many steps. A long description can become difficult to follow.
  3. Has no single writing format: Different people may describe the same steps differently. The wording must still be clear.
  4. Does not show paths visually: Choices and repeated steps may be easier to see in a flowchart.
  5. Cannot be executed directly: An algorithm written in ordinary language must be converted into a program before the computer can run that program.

Simple example

To add two numbers: read the two values, add them and display the sum. For inputs 8 and 5, the result is 13. These steps can be understood before writing any C code. They can also be used to write a program in another language. The algorithm is useful for planning, but the computer still needs an implementation to execute.

READ a, b
sum ← a + b
OUTPUT sum

Key points

  • Algorithms support reasoning before implementation.
  • Choose enough detail that another person can follow the steps.