What is an Algorithm? & Algorithm Examples


What is an Algorithm?

An algorithm is the sequence of steps a computer follows to perform actions. If we need to give an example from daily life, we can think of them as daily plans.
Remember, "Code flies, algorithm remains." Because we may not recognize or may confuse our own code 1 or 2 months later—where and what we did—but algorithms are universal and always understandable.

Additionally, displaying an algorithm with special geometric shapes is called a flowchart.

There are 3 ways to represent an algorithm:

  1. Writing the algorithm as plain text
  2. Writing the algorithm in pseudocode
  3. Showing the algorithm using a flowchart
Operators used in algorithms
  1. Data
  2. Identifier
  3. Variable
  4. Constant
  5. Assignment
  6. Counter
  7. Loop

Algorithm Examples

Algorithm to find which number is greater or smaller
  1. Start
  2. Enter number A
  3. Enter number B
  4. If A>B, Print (A is greater than B)
  5. If A<B, Print (B is greater than A)
  6. If A=B, Print (A is equal to B)
  7. Stop (Finish)
Addition operation algorithm
  1. Start
  2. Variables A, B, Total
  3. Read <- A
  4. Read <- B
  5. Total = A + B
  6. Print (Total)
  7. Finish
Addition operation algorithm