You are on page 1of 3

ANALYSIS AND DESIGN OF ALGORITHMS

LESSON 1: INTRODUCTION
Objective
By learning this Lesson you will able to:
Discuss what exactly mean Algorithm Basic Concepts of Analysis of Algorithm: Worst case An algorithm is an abstraction of a program to be executed

on a physical machine (model of Computation). The most famous algorithm in history dates from well before the time of the ancient Greeks: this is Euclids algorithm for calculating the greatest common divisor of two integers. 2. Algorithmic Algorithmic is a branch of computer science that consists of designing and analyzing computer algorithms 1. The design pertain to i. The description of algorithm at an abstract level by means of a pseudo language, and ii. Proof of correctness that is, the algorithm solves the given problem in all cases. 2. The analysis deals with performance evaluation (complexity analysis). Guys & Intelligent Gals, Let us learn why analysis of algorithm is needed and how the analysis is done. So first see the meaning of Analysis of algorithm. 3. Analysis of Algorithms (A of A) Analysis of algorithm is a field in computer science whose overall goal is an understanding of the complexity of algorithms. While an extremely large amount of research is devoted to worst-case evaluations, the focus in these pages is methods for average-case and probabilistic analysis. Properties of random strings, permutations, trees, and graphs are thus essential ingredients in the analysis of algorithms. The subject was founded by Knuth (who coined the term analysis of algorithms in the mid-sixties) and is well illustrated by his monumental series, The Art of Computer Programming. The field entertains close ties with a number of areas like discrete mathematics, combinatorial analysis, probability theory, analytic number theory, asymptotic analysis, complexity theory, and sometimes statistical physics. We start with defining the model of computation, which is usually the Random Access Machine (RAM) model, but other models of computations can be use such as PRAM. Once the model of computation has been defined, an algorithm can be describe using a simple language (or pseudo-language) whose syntax is close to programming language such as C or java.
3.1 An Algorithms Performance

Complexity and Average-case Complexity


How to remove the complexity of algorithm by Reduction

Points to Ponder
In this Lesson you will learn what exactly mean Algorithm Complexity in algorithm How to remove the complexity in the algorithm

1. Introduction The name Algorithm is given after the name of AlKhwarizmi, Ninth Century .I would like to give concerned history by putting philosophy thoughts. Abu Jafar Muhammad ibn Musa Al-Khwarizmi - [Born: about 780 in Baghdad (now in Iraq). Died: about 850] say

That fondness for science, that affability and condescension which God shows to the learned, that promptitude with which he protects and supports them in the elucidation of obscurities and in the removal of difficulties, has encouraged me to compose a short work on calculating by al-jabr and al-muqabala confining it to what is easiest and most useful in arithmetic. Rashid says, Without- loss of generality, may all your theorems be proved. If thy theorems fail deduction reasoning thou shalt apply induction reasoning with the most meticulous care. There are many definitions of Algorithm given by philosopher & authors. I would like to emphasis on some of them.

Definitions
An algorithm, named after the ninth-century mathematician AlKhowarizmi, is defined as follows: Roughly speaking:
An algorithm is a set of rules for carrying out calculation

ether by hand or on a machine.


An algorithm is a sequence of computational steps that

transform the input into the output.


An algorithm is a sequence of operations performed on data

The performance evaluation of an algorithm is obtained by totaling the number of occurrences of each operation when running the algorithm. The performance of an algorithm is evaluated as a function of the input size n and is to be considered modulo a multiplicative constant. The following notations are commonly use notations in performance analysis and used to characterize the complexity of an algorithm.
1

that have to be organized in data structures.

4A.283

Copy Right: Rai University

Please go through the following notations which are used everywhere where algorithm analysis is done.
3.2 QNotation (Same order)

The complexity of an algorithm is a function g(n) that gives the upper bound of the number of operation (or running time) performed by an algorithm when the input size is n. There are two interpretations of upper bound.
a. Worst-Case Complexity

This notation bounds a function to within constant factors. We say f(n) = Q(g(n)) if there exist positive constants n 0, c1 and c2 such that to the right of n 0 the value of f(n) always lies between c1g(n) and c2g(n) inclusive.

The running time for any given size input will be lower than the upper bound except possibly for some values of the input where the maximum is reached.
b. Average-Case Complexity

The running time for any given size input will be the average number of operations over all problem instances for a given size. Because, it is quite difficult to estimate the statistical behavior of the input, most of the time we content ourselves to a worst case behavior. Most of the time, the complexity of g(n) is approximated by its family o(f(n)) where f(n) is one of the following functions. n (linear complexity), log n (logarithmic complexity), n a where ae2 (polynomial complexity), an (exponential complexity). Guys now you are well known with the notations used for the analysis of algorithm. Now we will learn some measures of Algorithm analysis and how to remove the complexity in the algorithm.
c. Optimality

3.3 0-Notation (Upper Bound)

This notation gives an upper bound for a function to within a constant factor. We write f(n) = O(g(n)) if there are positive constants n 0 and c such that to the right of n 0, the value of f(n) always lies on or below cg(n).

3.4 W-Notations (Lower Bound)

Once the complexity of an algorithm has been estimated, the question arises whether this algorithm is optimal. An algorithm for a given problem is optimal if its complexity reaches the lower bound over all the algorithms solving this problem. For example, any algorithm solving the intersection of n segments problem will execute at least n 2 operations in the worst case even if it does nothing but print the output. This is abbreviated by saying that the problem has W(n 2) complexity. If one finds an O(n 2) algorithm that solve this problem, it will be optimal and of complexity Q(n 2).
d. Reduction

This notation gives a lower bound for a function to within a constant factor. We write f(n) = W(g(n)) if there are positive constants n 0 and c such that to the right of n 0, the value of f(n) always lies on or above cg(n).

Another technique for estimating the complexity of a problem is the transformation of problems, also called problem reduction. As an example, suppose we know a lower bound for a problem A, and that we would like to estimate a lower bound for a problem B. If we can transform A into B by a transformation step whose cost is less than that for solving A, then B has the same bound as A. The Convex hull problem nicely illustrates reduction technique. A lower bound of Convex-hull problem established by reducing the sorting problem (complexity: (nlogn)) to the Convex hull problem.

Summary
In this Lesson we have learnt:
Meaning of Algorithms: An algorithm is a set of rules for

carrying out calculation ether by hand or on a machine. 3.6 Algorithm Analysis


Analysis of Algorithm: Analysis of algorithm is a field in

computer science whose overall goal is an understanding of the complexity of algorithms.

An algorithm for a given problem is optimal if its

complexity reaches the lower bound over all the algorithms solving this problem.

References
1. The Design and algorithm of Computer Algorithm Aho, Hopcroft and Ullman 2. http://www.personal.kent.edu Notes

You might also like