Algorithms: Concepts and Representation

Definition of Terms

An algorithm is a finite sequence of well-defined and precise instructions that can be used to solve a specific problem. Algorithmic thinking is a way of getting to a solution through the clear definition of the steps needed. Computational thinking is a problem-solving method that expresses problems and solutions in ways a computer could also execute. Computational complexity is the amount of resources (time and memory) required to run an algorithm.

Steps to Resolve a Problem

Problem solving can be summed up in five points: define the problem by specifying the expected output; identify the required data input; determine how to process the inputs to obtain the desired output; implement the chosen process; and test the algorithm to ensure correctness and effectiveness.

Two methods commonly used: Stepwise Refinement (replacing existing steps with a new, more detailed version until each step is sufficiently detailed) and Top-Down Design (dividing a problem into sub-problems, which can in turn be divided further).

Characteristics of a Good Algorithm

  • Explicit: clear and obvious.
  • Precise/unambiguous: specified exactly and accurately, with no doubt about what to do next.
  • Effective/executable: must produce a result, with no impossible or unknown steps.
  • Finite/terminate: must have a beginning and an end.
  • Efficient: should not take more time or resources than required.
  • Must have an input and an output.

To judge the effectiveness of a solution, ask: does it work for all sets of data? Does it have unnecessary processes? Are actions repeated more often than necessary? Can it be simplified and still work?

Representing Algorithms

1. Structured English

Writing down the steps to follow in solving a problem, in chronological order – e.g. an algorithm to make tea: (1) put water into the coffee machine, (2) add tea, (3) plug in the machine, (4) wait ten minutes, (5) stop the machine, (6) unplug, (7) serve in a cup, (8) add sugar, (9) drink.

2. Flow Charts

A graphical representation of an algorithm using symbols to describe the flow of steps: a rounded terminator marks the begin/end; a rectangle indicates a process; a diamond (rhombus) indicates a decision; a parallelogram indicates input/output; an arrow indicates the direction of flow; and a circle joins two or more lines. Advantages: communicates a procedure clearly and acts as a design blueprint. Disadvantages: difficult for complex processes, symbols can’t be typed, and alterations are a hassle.

3. Pseudocode

An outline of a program written in a mixture of a programming-like language and English, helping programmers plan a program before writing it in an actual language. Good pseudocode should number each instruction (or use indentation), be unambiguous but effectively computable, and leave nothing out. An algorithm essentially consists of three parts: the header (identifies the algorithm), the declarative part (declares variables, constants, etc.) and the body (the instructions themselves).

Leave a comment

Your email address will not be published. Required fields are marked *

sponsors Ads