Skip to content

9618 · 9.2

Algorithms

An algorithm is simply a precise, step-by-step set of instructions designed to perform a task or solve a problem. Think of it as the logical blueprint that tells a computer exactly what to do, from start to finish.

Need to know

What you need to know

  • **Finiteness:** The algorithm must eventually stop after a finite number of steps. An infinite loop, for example, violates this property.
  • **Definiteness:** Every step must be precisely and unambiguously defined. For example, 'Add 5 or 6' is ambiguous; 'Add 5' is definite.
  • **Input:** An algorithm takes zero or more inputs. These are the values on which the algorithm will operate.
  • **Output:** An algorithm produces at least one output. This is the result of the computation, the solution to the problem.
  • **Effectiveness:** Each instruction must be simple enough that it can be carried out in a finite amount of time. It must be practically possible to execute the step.

Explanation

The Recipe for Solving Problems

  1. Define the Problem: Clearly identify the inputs, the required processing, and the expected outputs.
  2. Decompose into Steps: Break the overall problem down into smaller, more manageable sub-tasks.
  3. Sequence and Structure: Arrange the steps logically using sequence, selection (IFs), and iteration (loops).
  4. Refine and Test: Review the algorithm for clarity and correctness. Trace it with sample data to find any errors.