18
What is algorithm? Characteristics of algorithm Design method ALGORITHM

Algorithm - Introduction

Embed Size (px)

Citation preview

Page 1: Algorithm - Introduction

What is algorithm?

Characteristics of algorithm

Design method

ALGORITHM

Page 2: Algorithm - Introduction

An algorithm is a finite set of instructions that if followed,

accomplishes a particular task.

An input to an algorithm specifies an instance of the

problem.

An algorithm can be specified in a natural language or

pseudo code.

Algorithm can be implemented as computer programs.

algorithm

Page 3: Algorithm - Introduction

PROBLEM

ALGORITHM

COMPUTERINPUT OUTPUT

NOTATION OF ALGORITHM

Page 4: Algorithm - Introduction

INPUT: zero or more quantities externally supplied.

OUTPUT: at least one quantity is produced.

DEFINITENESS: Each instruction is clear and ambiguous.

FINITENESS: the algorithm terminates after a finite number of

steps.

EFFICIENCY: every instruction must be very basic.

UN AMBIGUITY: an algorithm must be expressed in a fashion

that is completely free for ambiguity.

Characteristics of algorithm

Page 5: Algorithm - Introduction

1. Understanding the problem.

2. Ascertaining the capabilities of computational device.

3. Choosing between exact and approximate problem solving.

4. Deciding the appropriate data structure.

5. Algorithm design techniques.

6. Method of specifying an algorithm.

7. Proving an algorithm’s correctness.

8. Analyzing an algorithm.

9. Coding an algorithm.

DESIGN METHODS

Page 6: Algorithm - Introduction

UNDERSTAND THE PROBLEM

DECIDING ON COMPUTATIONAL

EXACT VS APPOROXIMATEDATA STRUCTURE

DESIGN TECHNIQUES

DESIGN AN ALGORITHM

PROVE CORRECTNESS

ANALYZE THE ALGORITHM

CODE THE ALGORITHM

Page 7: Algorithm - Introduction

Reading the problem’s description carefully.

Ask questions and clarify the doubt arise in the problem.

Do some examples and the think about special cases.

Divide the problem into smaller problems until it become

manageable size.

1.Understanding the problem

Page 8: Algorithm - Introduction

In random access machine, instruction to be executed one

after another, one operation at a time.

Algorithm designed to be executed on such machines are

called sequential algorithm.

The central assumption of the RAM model does not called

for some new computers that can execute operations

concurrently. That is operation executed parallel.

Algorithm that take the advantage of operations that

executed concurrently is called parallel algorithm

2.Ascertaing capabilities of a computational device

Page 9: Algorithm - Introduction

The next principal decision is to choose between solving the

problem exactly or solving the problem approximately.

Exact algorithm: solve the problem exactly .

Appropriate algorithm: solve the problem approximately.

3. Choosing between exact and approximate problem solving

Page 10: Algorithm - Introduction

Some problem can not be solved exactly

- extracting square root

- solving non linear equations

- evaluating definite integrals

Exact algorithm can be slow because of the problem’s complexity.

- traveling salesman problem of finding the shortest path

through n cities

It is a part of more sophisticated algorithm that solves a problem

exactly

BENEFITS OFAPPROXIMATE ALGORITHM

Page 11: Algorithm - Introduction

defined as a particular scheme of organizing related data items.

Algorithm + Data structure = Programs.

Important for both design and analysis of algorithms

Some algorithm do not demand any ingenuity is representing

their inputs.

Some of the algorithm design techniques is used to structuring

or restricting data specifying a problem’s instance.

The variability is algorithm is due to in which the data of

program are stored.

4.Deciding the appropriate data structure.

Page 12: Algorithm - Introduction

An algorithm design technique is a general approach to solving

problems algorithmically that is applicable to a variety of

problems from different areas of computing

Merits:

Provide guidance for designing algorithms for new problem.

Algorithm are the cornerstone of computer science.

Used to classify the algorithm based on the design idea.

can serve as a natural way to both categorize and study

algorithms.

5. algorithm design technique

Page 13: Algorithm - Introduction

There are three options that are most widely used for

specifying algorithms.

Euclid’s algorithm

Pseudo code

Flow chart

6. METHOD OF SPECIFYING AN ALGORITHM

Page 14: Algorithm - Introduction

1. Euclid’s algorithm:

specified by simple English statement.

step by step form

2. Flow chart:

It is a method of expressing an algorithm by

diagrammatic representation.

It is very simple.

.

6. METHOD OF SPECIFYING AN

ALGORITHM (Cont.)

Page 15: Algorithm - Introduction

3. Pseudo code:

It is a mixture of natural language and programming

language constructs.

It is move precise than a natural language.

For simplicity, declaration of the variable omitted.

For, if and while statements are used to show the scope

of variables.

“ ” is used for assignment operation.

“// ” is used for comments

6. METHOD OF SPECIFYING AN ALGORITHM (cont.)

Page 16: Algorithm - Introduction

Once an algorithm has been specified, then its correctness

must be proved.

The algorithm yields a required result for every legitimate

input in a finite amount of time.

Proving correctness - mathematical induction.

In mathematical induction an algorithms iteration provide a

natural sequence of steps needs for proofs.

The notation of correctness for approximation is less

straight forward than it is for exact algorithm

7.Proving an algorithm’s correctness

Page 17: Algorithm - Introduction

• Efficiency of an algorithm can be measured in terms of

space and time.

• Space:

The number of units, it requires for memory storage.

• Time:

The amount of time needed for executing an algorithm.

Complexity of an algorithm is measured by calculating

the time taken, space required for performing the algorithm.

8.Analyzing algorithms

Page 18: Algorithm - Introduction

Once an algorithm has been selected, a 10-506 speed up may

be worth an effort.

An algorithm’s optimally is not about the efficiency of an

algorithm but about the complexity of the problem.

Another important issue of algorithmic problem solving is the

question of whether or not every problem can be solved by

algorithm.

9. Coding an algorithm