DAA
MODULE 1
PPT 1
ALGORITHMS
• Introduction to Algorithm Analysis
Time and Space Complexity
Elementary operations and Computation of
Time Complexity
Best, worst and Average Case Complexities-
Complexity Calculation of simple algorithms
Algorithms
• Algorithm means “a process or set of rules to
be followed in calculations or other problem-
solving operations”.
• Finite set of instructions that, if followed,
accomplishes a particular task.
• Therefore Algorithm refers to a set of
rules/instructions that step-by-step define
how a work is to be executed upon in order to
get the expected results.
• Definteness; Clear and Unambiguous: Algorithm
should be clear and unambiguous. Each of its steps
should be clear in all aspects and must lead to only
one meaning.
Eg: add 6 or 7 to x.
• Well-Defined Inputs: If an algorithm says to take
inputs, it should be well-defined inputs. An algorithm
takes zero or more inputs
• Well-Defined Outputs: The algorithm must clearly
define what output will be yielded and it should be
well-defined as well. An algorithm results in one or
more outputs
• Finite-ness: The algorithm must be finite, i.e. it
should not end up in an infinite loops or similar. All
operations can be carried out in a finite amount of
time
• Feasible/Effectiveness: The algorithm must be
simple, generic and practical, such that it can be
executed upon with the available resources. It must
not contain some future technology, or anything.
Each step in the algorithm must be easily understood
for some reading it
• Language Independent: The Algorithm designed
must be language-independent, i.e. it must be just
plain instructions that can be implemented in any
language, and yet the output will be same, as
expected.
• Algorithms that are definte and effective are
called computational procedures
• A program is expression of algorithm in a
programming language
Advantages of Algorithms:
• It is easy to understand.
• Algorithm is a step-wise representation of a
solution to a given problem.
• In Algorithm the problem is broken down into
smaller pieces or steps hence, it is easier for
the programmer to convert it into an actual
program.
Disadvantages of Algorithms:
• Writing an algorithm takes a long time so it is
time-consuming.
• Branching and Looping statements are difficult
to show in Algorithms.