An algorithm is a step-by-step procedure or a set of instructions for solving a problem or performing a task. Algorithms are the foundation of computer programming and are independent of specific programming languages.
To find a solution for the problem
To understand the flow of the problem
To understand the core idea behind a problem
To break down a complex problem into smaller and more manageable steps
To provide a straightforward explanation of how it works without getting too technical
Unambiguous – Steps should be clear and straightforward.
Input – An algorithm should have 0 or more inputs.
Output – An algorithm should have at least one output.
Finiteness – It should terminate after a certain number of steps.
Feasibility – The steps should be practical and possible to execute.
Independent – It must be applicable in any programming language.
Example of an Algorithm
Problem: Find the sum of two numbers..
In an algorithm, it is important to keep the following key elements in mind:
Terminals: Represent the start and end points.
Inputs: Identify the data required to process.
Process: Define the steps to solve the problem.
Output: Specify the result or solution.
A flowchart is a diagrammatic representation of an algorithm. It uses various symbols to represent different types of instructions or steps in a process, connected by arrows indicating the flow of the process.
Helps in Understanding – Makes it easy to visualize the process step by step.
Easy to Communicate – Explains the logic to others clearly.
Saves Time – Quickly identifies errors or problems in the process.
Helps in Debugging – Easier to find mistakes in code or logic.
Documentation – Acts as a record for future reference.
Symbols Used in Flowchart
We use following symbols and shapes to create a flowchart:
Example of an Alogorithm and Flowchart