What is an Algorithm?

An algorithm is a finite, ordered sequence of unambiguous instructions used to solve a computational problem.

Algorithm vs Program

Algorithm Program
Step-by-step procedure Implementation in programming language
Language independent Language dependent
Design phase Implementation phase
Finite logical steps Executable code

Characteristics of Algorithms

  1. Input: Algorithm takes zero or more inputs from the external environment
  2. Output: Algorithm produces at least one output as the result
  3. Definiteness: Each step must be clear, unambiguous, and precisely defined
  4. Finiteness: Algorithm must terminate after finite number of steps
  5. Effectiveness: Steps must be basic enough to be carried out by a human using basic operations

Algorithm Analysis

Why Analyze Algorithms?

To compare different algorithms and choose the best one for a given problem.

Analysis Parameters

1. Time Complexity

2. Space Complexity