Lecture 10
Lecture 10
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.
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.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
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
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/