You are on page 1of 2

Introduction to Algorithm – team computational biology

 A wise words when learning computer science

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

An algorithm is a set of instructions, sometimes called a procedure or a function that is


used to perform a certain task

 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 and backtracking

- 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

Example 1 : write an algorithm and draw a flow chart to calculate 24

Algorithm: Step 1: Input Base (2), Power (4)


Step 2 : Product = Base
Step 3 : Product = Product * Base
Step 4 : Product = Product * Base
Step 5 : Product = Product * Base
Step 6 : Print Product
Flowchart :

Baka, B. 2017. Python Data Structures and Algorithm. Packt


Publisher. Birmingham

You might also like