Algorithm and Flowcharts

Computer Science (Computer) — Learn about Algorithm and Flowcharts in Computer Science (Computer). Comprehensive study materials and practice questions.

Study Notes

Introduction to Algorithms and Flowcharts

In computer science, solving a problem requires a systematic approach. Before writing code in a programming language, a programmer must first design the logic of the solution. The two most common tools used for this logical planning are Algorithms and Flowcharts. This guide provides a comprehensive breakdown of these concepts, their functions, properties, and standard representations in accordance with the JAMB syllabus.

1. Definitions

  • Algorithm: An algorithm is a step-by-step, unambiguous procedure or set of rules designed to solve a specific problem or perform a particular task in a finite number of steps. It is written in plain, human-readable language (often as English-like statements or pseudocode) and is independent of any programming language.
  • Flowchart: A flowchart is a graphical or pictorial representation of an algorithm. It uses standard geometric symbols connected by arrows (flowlines) to show the step-by-step flow of execution and logic within a system or program.

2. Functions of Algorithms

Algorithms are the building blocks of computer programs. They are designed to carry out three primary functions:

  • Calculations: Performing mathematical computations, ranging from simple arithmetic (addition, subtraction) to complex scientific and statistical formulas (e.g., calculating the roots of a quadratic equation or finding the factorial of a number).
  • Data Processing: Handling, organizing, manipulating, and transforming raw data into meaningful information. This includes sorting lists, searching for specific records in a database, merging datasets, and filtering inputs.
  • Automated Reasoning: Executing logical decisions and operations based on specified conditions without human intervention. Examples include artificial intelligence decision paths, rule-based expert systems, and conditional branching in operating software.

3. Properties of an Algorithm

For an algorithm to be effective and correct, it must possess several fundamental properties (often formalized by computer scientist Donald Knuth):

  • Input Specified: The algorithm must have zero or more well-defined inputs. These are the starting quantities or data provided to the algorithm before execution begins.
  • Output Specified: The algorithm must produce at least one well-defined output, which is the result of the processing steps. The output must have a direct relationship to the inputs.
  • Definiteness (Unambiguity): Each step of the algorithm must be clear, precise, and unambiguous. There should be no double meaning; every instruction must be interpreted in exactly one way.
  • Finiteness: The algorithm must terminate after a finite number of steps. It cannot run infinitely; it must eventually complete its execution and stop.
  • Effectiveness (Feasibility): Every step of the algorithm must be basic enough to be carried out in practice, using paper and pencil, in a finite amount of time. The operations must be feasible and doable.
  • Generality: The algorithm should be generic enough to solve all problems of a particular class, not just a single specific instance (e.g., an algorithm to find the area of a circle should work for any radius value, not just a radius of 5).

4. Flowchart Symbols and Meanings

To ensure universal understanding, standard geometric shapes designated by the American National Standards Institute (ANSI) and ISO are used to construct flowcharts. Below are the key symbols you must identify for the JAMB exam:

  • Terminal (Oval / Rounded Rectangle): Represents the Start or Stop / End points of a flowchart. Every flowchart must begin and end with this symbol.
  • Input / Output (Parallelogram): Used to represent input operations (e.g., reading data from a keyboard, receiving variables) and output operations (e.g., displaying results on a screen, printing reports).
  • Process (Rectangle): Represents internal processing or computational tasks, such as calculations, variable assignments, and data manipulations (e.g., Area = length * width or Sum = A + B).
  • Decision (Diamond): Represents a logical conditional test or decision-making step. It typically has one entry flowline and two or three alternative exit paths (usually labeled Yes / No or True / False).
  • Flow Lines (Arrows): Used to connect symbols and indicate the sequential direction of execution or the control flow of the program.
  • Connector (Small Circle): Used to join different parts of a flowchart that are on the same page, preventing messy or crossing lines. It usually contains a letter or number (e.g., 'A') to show where the flow resumes.
  • Off-Page Connector (Pentagon / Home Plate shape): Used to link flowchart segments across different pages.
  • Loop / Repetition Symbol (Hexagon or Double-lined Rectangle): Sometimes used specifically to indicate initialization and control of iterative loops (e.g., FOR, WHILE structures).

5. Logical Structures in Flowcharts

When drawing or analyzing flowcharts for programming problems, you will encounter three fundamental control structures:

  1. Sequence: Steps are executed one after another in a straight, linear path.
  2. Selection (Branching): The flow splits into alternative paths based on a condition (using the Decision diamond).
  3. Iteration (Looping): A block of steps is repeated multiple times either as long as a condition is true, or until a condition becomes true.

Master Algorithm and Flowcharts Now!

Test your understanding with actual past questions and get instant, AI-powered explanations for every answer.

Start Free CBT Practice