Computer Basics - What is an Algorithm

1. What is an Algorithm?

An algorithm is a step-by-step procedure or set of rules designed to solve a specific problem or perform a particular task.

  • Think of it as a recipe for solving a problem.

  • Each step must be clear, finite, and unambiguous.

Key Characteristics of an Algorithm:

  1. Finite – Must end after a limited number of steps.

  2. Well-defined – Each step is clear and unambiguous.

  3. Input – Can have zero or more inputs.

  4. Output – Produces at least one output.

  5. Effective – Steps must be practical and executable.

Example (Simple Algorithm to Add Two Numbers):

  1. Start

  2. Read number A and number B

  3. Sum = A + B

  4. Display Sum

  5. Stop


2. Types of Algorithms

  1. Simple/Sequential Algorithm – Executes steps one after another.

  2. Conditional/Decision Algorithm – Executes steps based on a condition (if-else).

  3. Looping/Iterative Algorithm – Repeats steps until a condition is met (for, while loops).

  4. Recursive Algorithm – A step calls itself to solve a smaller version of the problem.


3. Advantages of Using Algorithms

  • Solve problems systematically

  • Make programming easier

  • Improve efficiency and reduce errors

  • Help in designing flowcharts and code


4. What is a Flowchart?

A flowchart is a diagrammatic representation of an algorithm.

  • It shows the sequence of steps using different symbols.

  • Helps visualize the logic before programming.

Common Flowchart Symbols:

  1. Oval (Terminator) – Start or Stop

  2. Rectangle (Process) – Process or action step

  3. Parallelogram (Input/Output) – Input or output operation

  4. Diamond (Decision) – A decision point (Yes/No or True/False)

  5. Arrow – Shows the flow of steps

Example (Flowchart for Adding Two Numbers):

(Start) → (Input A, B) → (Sum = A + B) → (Display Sum) → (Stop)

5. Steps to Create an Algorithm and Flowchart

  1. Understand the Problem – Identify input, output, and requirements.

  2. Define the Steps – Write a clear, sequential procedure.

  3. Choose Tools – Decide whether to use pseudocode, flowchart, or both.

  4. Draw Flowchart – Use proper symbols for each step.

  5. Test – Check with example inputs to ensure correctness.


6. Relationship Between Algorithm and Flowchart

  • Algorithm: Step-by-step written procedure (textual).

  • Flowchart: Graphical representation of the algorithm.

  • Both are used to plan and design a solution before coding.


In short:
An algorithm is a set of instructions to solve a problem, and a flowchart is the visual map of that algorithm. They help programmers think logically, avoid mistakes, and efficiently write programs.