Algorithm
An algorithm is a sequence of steps to be carried out in order to solve a given problem.
Characteristics of Algorithm:
It includes:
- Input: An algorithm must work on externally provided one or more input.
- Output: An algorithm must provide one or more output.
- Finiteness: An algorithm must terminate after finite number of steps.
- Definiteness: The steps of an algorithm must be definite without leading to multiple meanings.
- Effectiveness: The steps of an algorithm must be effective so that it can be solved easily.
Analysis of Algorithm
An algorithm can be analysed for its performance based on time and storage it needs. The time required by an algorithm is known as time complexity and the storage required by the algorithm is known as space complexity.
Time Complexity
The total amount of computer time needed to complete the execution of an algorithm is called as time complexity.
Space Complexity
The total amount of computer memory needed to complete the execution of an algorithm means a program is called space complexity. It includes fixed space like code, statement, instructions, constants and variables, like problem dependent variables, stacks.