0% found this document useful (0 votes)
9 views27 pages

Daa Unit-1 PPT-1

DAA UNIT-1 PPT2

Uploaded by

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

Daa Unit-1 PPT-1

DAA UNIT-1 PPT2

Uploaded by

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

VIDEO-1

DESIGN AND ANALYSIS OF ALGORITHMS


III B.Tech CSE , A.Y:2020-21,SEMESTER-2
JNTUK KAKINADA-R16

KALLAM HARANADHAREDDY INSTITUTE OF


TECHNOLOGY
Dr K Venkata Subba Reddy, Professor&HOD, Department of CSE,KHIT
TOPICS TO BE COVERED IN UNIT-I
Introduction:

 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.

Why Algorithms are required?

To design better programs algorithms are required.

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.

2. Output − An algorithm should have 1 or more well-defined


outputs, and should match the desired output.

3. Unambiguous − Algorithm should be clear and


unambiguous. Each of its steps (or phases), and their
inputs/outputs should be clear and must lead to only one
meaning.

4. Finiteness − Algorithms must terminate after a finite


number of steps.
6
5. Effectiveness: Each step must be simple and should take a
Algorithm Advantages and
Disadvantages
Algorithm Advantages
1. Effective Communication
2. Easy Debugging
3. Easy and Efficient Coding
4. Independent of Programming Language

Algorithm Dis-Advantages
5. Developing algorithm for complex problems would be time
consuming and difficult to understand.

6. Understanding complex logic through algorithms can be


very difficult.
7
ALGORITHM SPECIFICATIONS

8
Algorithm Specifications
We can describe an algorithm in many ways.

1. Natural language: implement a natural language like


English

2. Flow charts: Graphic representations denoted flowcharts,


only if the algorithm is small and simple.

3. Pseudo code: This pseudo code skips most issues of


ambiguity; no particularity regarding syntax programming
language.

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

 The algorithm calls itself with smaller input values and


obtains the results by simply accomplishing the operations
on these smaller values.

 Generation of factorial, Fibonacci number series are denoted


as the examples of recursive algorithms.

16
PERFORMANCE ANALYSIS

17
Performance Analysis
 Before design the algorithm, we should analyze the
algorithm.

 The performance of an algorithm can be analyzed based on


following principles:

1. Correctness: Produce Correct results


2. Simplicity : It helps in writing and modifying program
easily.
3. Optimality : Optimality helps in finding the best possible
way to
solve given problems
4. Readability: Readability makes the code readable
5. Time complexity
6. Space complexity
18
Performance Analysis
Time complexity
 Time complexity is the amount of time taken by an algorithm
to execute a task.
 The time complexity of a program is the amount of time
taken to solve a problem or function of size as inputs.
 If the time complexity of an algorithm is better, then the
algorithm will carry out its work as fast as possible.

Measures of Time Complexity


1. Average Case: The amount of time the algorithm takes on
an average set of inputs.
2. Worst Case: The amount of time the algorithm takes on the
worst possible set of inputs.
3. Best Case: The amount of time the algorithm takes on best
set of inputs. 19
Performance Analysis

Measures of Time Complexity

Size of Input:

The running time of a program can be expressed as a


function of the size of the input. The size of the input is
typically denoted as n and the running time of the
algorithm as T(n).

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

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy