Demonastrate various important algorithms for learning better programming.
A step by step procedure to solve logical problems. Each step has clear instructions.
A recipe is a good example of an algorithm because it says what must be done, step by step. It takes inputs (ingredients) and produce an output (complete dish). Informally, an algorithm can be called "a list of steps".
Various types of algorithm exists. Sometime it called algorithm design techniques. Most funndamental types of algorithms are:
- Bruthforce: Try all possibilities.
- Divide and Conquer: Break large problem into distinct sub problems.
- Transformation: Convert problem into another one.
- Dynamic Programming: Break problem into overlapping sub problems.
- Greedy: Reapeatly do until find the best one.
- Iterative Improvement: Reapeatedly improve current solution.
- Randomization: Use random numbers,
Algorithm must have 5 properties:
- Input Specified: Input is from a specified set, I.
- Output Specified: Output is from a specified set, O
- Effectiveness: Its steps are defined precisely and can be done.
- Finiteness: Finitely many steps are executed, each taking finite time.
- Correct: The output is correct.
-
A measure of the amount of resources consumed in solving a problem of size n
- Time
- Space
-
Code the algorithm, run it with some specific input and measure time taken
-
Big Oh(asymptotic analysis) provies a formula that associate n the problem size, with t, the processing time required to solve the problem.
For a particualr problem there can be many solutions. It is important to analysis the given context, constraint etc. then analysis the complexity then choose the algorithm.