Anda di halaman 1dari 4


Computer Era
• Pre Computer Era
– Focus was on Computability Theory (What can be
Algorithms and Problem Solving computed and what cannot be computed?)

• Post Computer Era
– Focus is on Complexity Theory (How well can it be

What is an algorithm? Algorithm Properties

• An algorithm is a sequence of unambiguous An algorithm must have following properties:
instructions for solving a problem, 1. Finiteness: terminates after a finite number of steps
i.e., for obtaining a required output for any 2. Definiteness: thoroughly and unambiguously
legitimate input in a finite amount of time. specified
problem 3. Input: valid inputs are clearly specified
4. Output: can be proved to produce the correct output
given a valid input
5. Effectiveness: steps are sufficiently simple and
input computer output


Some Well-known Computational Problems Why study algorithms and performance?

• Sorting • Algorithms help us to understand scalability.
• Searching • Algorithmic mathematics provides a language for
• Shortest path talking about program behavior.
• Minimum spanning tree • Performance is the currency of computing
• Traveling salesman problem • Performance often draws the line between what is
• Knapsack problem feasible and what is impossible.
• Chess
• Towers of Hanoi.

Basic Issues Related to Algorithms Analysis of Algorithms

• How to design algorithms
• How good is the algorithm?
• How to express algorithms – Correctness
– Time efficiency
• How to analyze algorithm efficiency? – Space efficiency
– Theoretical analysis
– Empirical (experimental) analysis • Does there exist a better algorithm?

• Proving correctness

• Optimality


Efficiency Measures Efficiency Measures (Space Time Tradeoff )

Example : Think of a GUI drop-down list box that displays a
• Performance of a solution list of employees whose names begin with a specified
• Most of the software problems do not have a single sequence of characters. If the employee database is on a
best solution. different machine, then there are two options:
• Option a: fire a SQL and retrieve the relevant
• Then how do we judge these solutions?
employee names each time the list is dropped down.
• Option b: keep the complete list of employees in
memory and refer to it each time the list is dropped
• In your opinion which is the preferred option and

Time Space Tradeoff Kinds of Analysis

• Worst-case: (usually)
• This example does not have a unique solution. It – T(n) = maximum time of algorithm on any input of
depends on various parameters which include: size n.
– The number of employees • Average-case: (sometimes)
– The transmission time from the database server to – (n) = expected time of algorithm over all inputs of
the client machine size n.
– The volume of data transmission each time – Need assumption of statistical distribution of
– The frequency of such requests.
• Best-case
– The network bandwidth
– Cheat with a slow algorithm that works fast on
• Very difficult to get a solution which is optimal in
some input.
terms of both the time and space.


More important than performance: Improving the performance of a solution
• modularity
• correctness By improving the
• maintainability • algorithm design,
• functionality • database design,
• robustness • transaction design,
• user-friendliness • paying attention to the end-user psychology,
• programmer time • continuous improvements in hardware and
• simplicity communication infrastructure.
• extensibility
• reliability

Fundamental data structures Some of the Algorithm Design techniques

• List :array, linked list, string
• Brute force
• stack • Divide and conquer
• queue • Greedy approach
• priority queue • Dynamic programming
• Backtracking
• graph • Space and time tradeoffs
• tree
• set and dictionary