0% found this document useful (0 votes)
10 views

Lecture 10

The document discusses performance analysis of algorithms including space complexity, time complexity, and asymptotic notation. Space complexity is the amount of memory needed, time complexity is the amount of computer time needed, and asymptotic notation describes upper and lower bounds of time complexity.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Lecture 10

The document discusses performance analysis of algorithms including space complexity, time complexity, and asymptotic notation. Space complexity is the amount of memory needed, time complexity is the amount of computer time needed, and asymptotic notation describes upper and lower bounds of time complexity.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Performance Analysis

Course No.: 0714 09 CSE 2151, Course Title: Data Structures and Algorithms
Electronics and Communication Engineering Discipline, Khulna University, Khulna
Md. Farhan Sadique
Email: [email protected]
This lecture is not a study material. Use this lecture as an outline. Follow the outline to study from the mentioned sources
after each section header. The sections of this lecture have been prepared from the mentioned sources.

1. Introduction (Ellis Horowitz et al.: 1.3)


There are many criteria upon which we can judge an algorithm. For instance:
• Does it do what we want it to do?
• Does it work correctly according to the original specifications of the task?
• Is there documentation that describes how to use it and how it works?
• Are procedures created in such a way that they perform logical sub-fuctions?
• Is the code readable?
There are other criteria (computing time and storage requirements) for judging algorithms that have a more
direct relationship to performance.
2. Space Complexity (Ellis Horowitz et al.: 1.3.1)
The space complexity of an algorithm is the amount of memory it needs to run to completion. The space
needed by an algorithm is seen to be the sum of the following components:

The space requirement S(P) of any algorithm P may therefore be written as S(P) = c + Sp (instance
characteristics), where c is a constant.

For algorithm 1.5, Sp = 0. Therefore, S(P) = c + 0 = c


Data Structures and Algorithms – Lecture 10 Md. Farhan Sadique

For algorithm 1.6, SSum(n) ≥ (n + 3). Therefore, S(P) ≥ c + (n + 3).

For algorithm 1.6, The recursion stack space needed is ≥ 3(n + 1). Therefore, S(P) ≥ c + 3(n + 1).
3. Time Complexity (Ellis Horowitz et al.: 1.3.2, https://www.geeksforgeeks.org/understanding-time-complexity-simple-
examples/)

The time complexity of an algorithm is the amount of computer time it needs to run to completion. The time
T(P) taken by a program P is the sum of the compile time and the run (or execution) time. We concern
ourselves with just the run time of a program. The run time is denoted by tp (instance characteristics).
Instead of measuring actual time required in executing each statement in the code, Time Complexity considers
how many times each statement executes.

2
Data Structures and Algorithms – Lecture 10 Md. Farhan Sadique

For algorithm 1.8, the number of program steps is 2n + 3.

4. Asymptotic Notation (Ellis Horowitz et al.: 1.3.3, https://www.geeksforgeeks.org/understanding-time-complexity-


simple-examples/, https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/, https://www.geeksforgeeks.org/types-
of-asymptotic-notations-in-complexity-analysis-of-algorithms/)

Big-O is a way to express the upper bound of an algorithm’s time complexity, since it analyses the worst-
case situation of algorithm.

3
Data Structures and Algorithms – Lecture 10 Md. Farhan Sadique

Omega notation represents the lower bound of the running time of an algorithm. Thus, it provides the best-
case complexity of an algorithm.

4
Data Structures and Algorithms – Lecture 10 Md. Farhan Sadique

Theta notation is used for analyzing the average-case complexity of an algorithm.

Task: Compare between the searching and sorting algorithm discussed in Lecture 8 based on their time
complexity.

5
Data Structures and Algorithms – Lecture 10 Md. Farhan Sadique

Bibliography
• Book: Fundamentals of Computer Algorithms, Second Edition – Ellis Horowitz, Sartaj Sahni and Sanguthevar
Rajasekaran.
• Website: https://www.programiz.com/dsa/greedy-algorithm
• Website: https://www.javatpoint.com/dynamic-programming
• Website: https://www.geeksforgeeks.org/understanding-time-complexity-simple-examples/
• Website: https://www.geeksforgeeks.org/analysis-algorithms-big-o-analysis/
• Website: https://www.geeksforgeeks.org/types-of-asymptotic-notations-in-complexity-analysis-of-algorithms/

You might also like