Basic Two
Basic Two
constant Ο(1)
logarithmic Ο(log n)
linear Ο(n)
quadratic Ο(n2)
cubic Ο(n3)
polynomial nΟ(1)
exponential 2Ο(n)
How to Write an Algorithm?
As we know that all programming languages share basic code constructs like
loops (do, for, while), flow-control (if-else), etc. These common constructs can
be used to write an algorithm.
Problem − Design an algorithm to add two numbers and display the result.
Algorithms tell the programmers how to code the program. Alternatively, the
algorithm can be written as −
Algorithm Analysis
To solve a problem based on the greedy approach, there are two stages
Feasible solution
Optimization
In divide and conquer approach, the problem in hand, is divided into smaller
sub-problems and then each problem is solved independently. When we keep
on dividing the subproblems into even smaller sub-problems, we may
eventually reach a stage where no more division is possible. Those "atomic"
smallest possible sub-problem (fractions) are solved. The solution of all sub-
problems is finally merged in order to obtain the solution of an original
problem.
Merge Sort
Quick Sort
Binary Search
Strassen's Matrix Multiplication
Closest pair (points)
Dynamic Programming