0% found this document useful (0 votes)
1 views5 pages

Design and Analysis of Algorithms OCR

The document provides an introduction to algorithms, defining them as systematic procedures for solving computational problems through a finite set of steps. It outlines key properties of algorithms, including finiteness, definiteness, input, output, and effectiveness, and discusses the study of algorithms, which encompasses devising, expressing, validating, analyzing, and testing algorithms. Additionally, it introduces examples of algorithms, such as Euclid's Algorithm for finding the greatest common divisor (GCD) of two integers.

Uploaded by

Vandana Vijayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1 views5 pages

Design and Analysis of Algorithms OCR

The document provides an introduction to algorithms, defining them as systematic procedures for solving computational problems through a finite set of steps. It outlines key properties of algorithms, including finiteness, definiteness, input, output, and effectiveness, and discusses the study of algorithms, which encompasses devising, expressing, validating, analyzing, and testing algorithms. Additionally, it introduces examples of algorithms, such as Euclid's Algorithm for finding the greatest common divisor (GCD) of two integers.

Uploaded by

Vandana Vijayan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Chupter J

Introduction to Analysis and Design of Algorithms

1.1 Introduction

Before entering into the colorful environment of algorithms and their design, let us
question ourselves about how almost all the day-to-day industrial problems dre solved, The
immediate answer is “a systematic approach”. It enables the people all around the world
to quickly access und retrieve Jarge amounts of information, In order to do so, a
systematic approach or plan is. to be made for finding the best website of the search
requested and the best route on which the data is to be traveled to reach in time. Ln the
sume way, in manufiusturing and other commercial settings, itis often important to allocate
secures resources in the most beneficial way. An oil company may wish to know where to
pluce its wells in order to imiuximize ils expected profit. Like wise, we cun take so many
distinet cxumples whether it may be a biological industry, a software industry or a norma!
computational problem. For all the solutions there should be systematic approach which is
none other than an Algorithm,

1.2. What is an Algorithm?

Informally, an algorithm is any well — defined computational procedure that takes some
values as “input? and produces some value, or set of values, as “output”. An algorithm i is
thus“ @ sequence of computational stepy (uit transforny the input nite the output,’

We cun also view an algorithm us a tool for solving a well-specified “computational


problem”. The statement of the problem specifies in general terms the desired input /
output
relationship, The ulgorithm describes a specific computational procedure for achieving that
input /output relationship,

In simple terms we can say that “An algorithm is.a step—by~step procedure for.
performing some task in a finite amount of time”.

Definition:

Aa algorithm is composed of a finite set of steps each of which muy require one or more
operations. Every operation may be characterized as either a simple or complex. Operations
performed on scalitr quantities are termed as simple, while Operations performed on vector
data normally termed as complex,

2 The Design & Analysis of Algorithm


Properties of Algorithm:
The following are the five important properties (features) of algorithm,

i. Finiteness a Definiteness
3. » Input 4. Output
5: Effectiveness

. Finiteness: An algorithm must always terminate after a number of steps. If we trace out
the instructions of an algorithm, then for all cases. the algorithm terminates after a finite
number of steps.

2. Definiteness: Each operation must be definite meaning that it must be perfectly clear.
Each step of an algorithm must be precisely defined. The actions to be carried out
must be rigorously and unambiguously specified for each case,

3. Input: An algorithm has zero or more “inputs” quantities thal are given to it initially
before

the algorithm begins, or dynamically as the algorithm runs. ‘These inputs are taken from

specified set of objects. These inputs ure extremely supplied to the algorithm.

4, Output: An algorithm has one or more “output” quantities that have a specified relation
to the inputs: An algonthm produces atleast one or more outputs.

§. Effectiveness: Each operation should be effective i.e., the operation must be able to
carryout in finite amount of time. An algorithm is generally expected to be “effective”, in
the sense that its operations must all be sufficiently basic that they can in principle be
done exactly and in a finite length of time by some one using peneil and paper.

1.3 Study of Algorithms

Analgorithmic approach is widely accepted in computer science field. The study of


algorithms
includes many important and active areas of research. There are five distinct areas of study
one
canidentify,

1) How to devise algorithms?


2) How to express algorithms?
3) How to validate algorithms?
4) How to analyze algorithms?
5) How to test a Program?

(1) How to devise algorithms?

Creating an algorithm is an art which may never be fully automated. A major goal of this
book is to study various design techniques that have proven to be useful in that they have
often yielded good algorithms. By mastering these design strategies, it will become easier
for
you to devise new and useful algorithms. Many of the chapters of this book are organised

Tunoduction 3

around what we believe are the major methods of algorithm design. ‘I'he reader may now
wish to glance back at the table of contents to see what these methods are called. Some of
these technologies may already be familiar, and some have been found to be so useful in
fields other than Computer science such as operations research and electrical engineering,
In
this boak, we can only hope to give an introduction to these many approaches to algorithm
formulation. All of the approaches we consider have applications in a variety of areas
inciuding Computer science. But some important design techniques such as linear,
nonlinear,
and integer programming are not covered here as they are traditionally covered in other
courses:

2) How to express algorithms?

+ One must express the algorithm in a structured way by using a programming


language

* such that the computer understands the problem.

* Every procedure should carefully specify its input and output variables,

+ The flow of program should generally be Top Down approach


The documentation should be short and meaningful
Use subroutines whenever necessary

3) How to validate algorithms?

Once an algonihm is devised and expressed, it is necessary to show that it computes the
correct answer for all possible legal inputs. We refer to this process as algorithm
validation. The purpose of validation is to assure us that this algorithm will work correctly
independent of the issues concerning the programming language. Once the validity of the
method has been shown, a program can be written and a second phase begins. This
phase is referred to as Program Proving or sometimes as Program Verification. A
proo! of correctness requires that the solution be started in two forms one form is usually
4s 1 program which ts annotated by a set of assertions about the input and output variables
of the program. The second fornyis called a specification, and this may also be expressed
in the predicate calculus. A proof consists of showing that these two forms are equivalent
in that for every given legal input, they describe the same output. A complete proof of
program correctness requires that each statement of the programming language be
precisely defined and all basic operations be proved correct. All these details may cause a
prool to be very much longer than the program,

4) How to analyze algorithms?

As an algorithm is executed, it uses the computers central processing unit (CPU) to perform
operations and its memory (both immediate and auxiliary) to hold the program and data.

4 The Design & Analysis of Algorithin


Analysis of algorithms or performance unalysis refers to the task of determining
how much computing time and storage an algorithm requires. ‘This is a challenging area
which sometimes require great mathematical skills. An important result of this study is that
it
ullows you to make quantitative judgements about the value of one algorithm over another.

Another result is that it allows you to predict whether the software will meet any efficiency
constraints that eaist.

5) How to test a program?

‘Testing is s stage of implementation which is amied at ensuring that program works


accurately and efficiently before the live operation starts. Testing a program consists of two
phuses: Debugging and profiling (or performance measurement) :

Debugging is the process of executing progrims on sample data sets to determine whether
faulty results oceur and, if so, to correct them. However, as ¥. Dijkstra has pointed out,
“debugging can only point to the presence of errors, bul not fo their absence”, The cases in
which we cannot verify the correctness of output on sample data, the following strategy cin
be employed: let more than one programmer develop programs for the same problem,
and compare the outputs produced by these programs. If the outputs match, then there is as
good chance that they are correct. A proof of correctness is much more valuable than a
thousand tests (if that proof is correct). Since it guarantees that the program will work
correctly for all possible inputs.
Profiling or performance measurement is the process of executing a correct program on
data sets and measuring the time and space it lakes to compute the results. These timing
figures ure useful in that they may confirm a previously done analysis and print out logical
places to perform useful optimization.
ee
1.4 Algorithm Examples

Now as we know what aralgorithm is.and what are its features, let us move to some
examples
for illustrating the notion of an algorithm. For time being. Let us take an example of finding
the
GCD of two non-negative and not-both-zero integers with the help of the sixth feature of un
algorithm i.e., solving a single problem,by differentalgorithm techniques, .

Recall that the GCD (greatest common divisor) of two non negative, not-both-zere integers
m
and », denated by ged (nm, 7) is defined as the largest integer that divides both mand
mevenly,

Se

Technique 1: (Euclid’s Algorithm)

Buclid of Alexindria has oudines a most famous algorithm for finding the GCD and hence the

You might also like