Professional Documents
Culture Documents
Introduction To Algorithm
Introduction To Algorithm
Leraning computer will teach you about time and space, you will learn data structure for
optimal space and learn algorithm for optimal time.
The study of algorithms is also important because it trains us to think very specifically
about certain problems.
Definition
Elements of algorithm
- Sequential operations
- Actions based on the state of a data structure
- Iteration, repeating an action a number of times
- Recursion, calling itself on a subset of inputs
Algorithm design
- Divide and conquer, breaking a problem into smaller sub problems and then
combining the results to obtain a global solution
- Greedy algorthms, often involve optimization and combinatorial problems
- Dynamic programming, useful when our sub problems overlap
- Recursion
o Terminates when a base case reached
o Each recursive call requires space in memory
o An infinite recursion results in a stack overflow error
o Some problems are naturally better suited to recursive solutions
- Iteration
o Terminates when a defined condition is met
o Each iteration is not stored in memory
o An infinite iteration will run while the hardware is powered
o Iterative solutions may not always be obvious
Backtracking
A form of recursion, where we are presented with a number of options at each node
Flowchart
1. Define the process and identify the scope of the flow diagram
2. Identify project team members that are to be involved in the
construction of the process flow diagram
3. Define the different steps involved in the process and the
interrelationships between the different steps (all team members
should help develop and agree upon the different steps for the
process)
4. Finalize the diagram, involving other concerned individuals as
needed and making any modifications necessary
5. Use the flow diagram and continuously update it as needed
Example