Daa Unit-1 PPT-1
Daa Unit-1 PPT-1
What is an Algorithm
Algorithm Specification, Pseudo code Conventions
Recursive Algorithm
Performance Analysis
Space Complexity, Time Complexity
Amortized Complexity
Asymptotic Notation
Practical Complexities, Performance Measurement.
2
What is an Algorithm?
Def: An Algorithm is a step-by-step procedure to
solve computational problems.
(Or)
Def: An Algorithm is a finite sequence of
steps/instructions to solve a problem.
3
Algorithms-Real Time Examples
1. Preparation of Tea.
2. Construct a building
3. Google Maps: Finding Shortest path among two cities
4. YouTube Recommendation System-Shopping Sites
4
Difference between algorithms and programs
1. Algorithms are written 1. Programs are written
at Design phase/design time in SDLC. at Implementation time.
2. The person who write algorithm should
have Domain Knowledge. 2. Programmer writes program,
may or may not have domain
knowledge
3. Use any language (English language or
mathematical notation) to write an
3. writing programs use only
algorithm.
Programming language like C,
C++, Java, Python.
4. While writing an algorithm, we don’t
bother hardware (hw)/Operating 4. In contrast to that when we
system(OS). write programs, it is
dependent on hw/ OS.
5. After writing an algorithm, we analyze
the algorithm : (a)Are we achieving the 5. after wring the program we do
results perfectly or not (b) Checking testing (run and check the
the efficiency of the algorithm in terms program).
of time and space. 5
Algorithm Characteristics
1. Input − An algorithm should have 0 or more well-defined
inputs.
Algorithm Dis-Advantages
5. Developing algorithm for complex problems would be time
consuming and difficult to understand.
8
Algorithm Specifications
We can describe an algorithm in many ways.
9
Algorithm Vs Flowchart Vs Pseudo Code
10
Algorithm Specifications
11
Algorithm Specifications-Pseudocode
Conversion
12
Algorithm Specifications-Pseudo code
Conversion
13
Algorithm Specifications-Pseudo code
Conversion
Ex: Finding max of given element in an array
14
RECURSIVE ALGORITHM
15
Recursive Algorithm
16
PERFORMANCE ANALYSIS
17
Performance Analysis
Before design the algorithm, we should analyze the
algorithm.
Size of Input:
https://www.youtube.com/watch?v=sn1ugY-jzQE
20
Performance Analysis
21
Performance Analysis-Time Complexity
https://www.youtube.com/watch?v=sn1ugY-jzQE
22
Performance Analysis
23
Performance Analysis-Space Complexity
Find Space
Complexity of
an algorithm
24
Performance Analysis-Space Complexity
Find Space Complexity of an algorithm
25
Performance Analysis-Space Complexity
Find Space Complexity of an algorithm
26
THANK YOU
27