Lec-2 Basics of Algorithm
Lec-2 Basics of Algorithm
(BCAE0106)
Presented by:
Akanksha
Assistant Professor
Dept. of Computer Engineering & Applications, IET,
GLA University, Mathura
Introduction
Algorithm
Need of an Algorithm
How to write an algorithm
Algorithm characteristics
Applications of an Algorithm
Good qualities of an Algorithm
Algorithm
5
Need of an Algorithm?
To understand the flow of the problem.
To measure the behavior (or performance)
of the methods in all cases (best cases,
worst cases, average cases)
We can measure and analyze the
complexity (time and space) of the
problems concerning input size without
implementing and running it; it will reduce
the cost of design.
6
How to Write Algorithm?
Natural Language
Flow Chart
Programming Language
Pseudo code
7
Natural Language
Step 1: Start
Step 2: Declare variables Step 1 − START
a, b and sum.
Step 2 − Get values
Step 3: Read values for a
of a & b
and b.
Step 4: Add a and b and Step 3 − c ← a + b
assign the result to a
variable sum. Step 4 − Display c
Recommendation System
E-Commerce Categories
15
Qualities of Good Algorithm:
What Makes a Good Algorithm?
Faster?
Less space?
Easier to code?
Easier to maintain?
16
Qualities of Good Algorithm:
The factors that we need to consider while determining the
quality of a good Algorithm are:
Time: The amount of time it takes to run as a function of
the length of the input is known as time requirement.