Introduction to Algorithm
Algorithm
An Algorithm is any well-defined computational procedure or instructions that takes some input and produces some output.
An algorithm is a step-by-step procedure to solve computational problems. It can be written in any comfortable language. It is a pseudo code of the actual program/code. Algorithms are written before actual coding.
What kind of problems are solved by Algorithms?
- Sorting
- Searching
- Finding the Shortest Path
- Making Coin Change
- Minimum cost Matrix Multiplications
- And more
Characteristics of Algorithm
Input: An Algorithm can take zero(0) or more inputs.
Output: It must give at least one(1) or more outputs/results.
Definiteness: Every statement must be clear and unambiguous.
Finiteness: Algorithm must terminate at some point.
Effectiveness: It should not have any unnecessary steps.
Which are the techniques used in Algorithms?
Divide & Conquer, Greedy Methods, Dynamic Programming, etc.
In Computer Science, algorithmic efficiency is a property of an algorithm that describes the number of computational resources used by the Algorithm.
Time Complexity
Time complexity is a function that shows the amount of time an algorithm takes in terms of the amount of input to the algorithm.
Space Complexity
Space complexity is a function that shows the amount of space(memory) an Algorithm takes in terms of the amount of input to the algorithm.
Best Case
In the Best Case Analysis, we calculate a lower bound on the running time of an algorithm.
Worst Case
The worst-case time analysis of the Algorithm is the longest-running time for any input of size n.