SlideShare a Scribd company logo
Data Structures and 
Algorithms 
Introduction 
Muhammad Hammad Waseem 
m.hammad.wasim@gmail.com
Course Outlines 
• Asymptotic and Algorithm Analysis 
• Complexity Analysis of Algorithms 
• Abstract Lists and Implementations 
• Arrays 
• Linked Lists, Doubly Linked Lists 
• Stacks 
• Queues, Priority Queues, DE-queues, 
• Trees, Binary Search Trees, B-Trees, Balanced Search Trees, 
• Graph and Direct Acyclic Graph Algorithms, 
• Sorting Algorithms: Bubble Sort, Quick Sort, Merge Sort, Heap sort, 
• Minimum spanning trees, Shortest Path Problems, 
• Hashing, Chained Hash Tables, Double Hashing. 
MHW 2
Course Objective 
• Enable the students to understand various ways to organize data, 
• Understand algorithm to manipulate data, 
• Use analyses compare various data structure and algorithms, 
• Select, apply and implement relevant data structure and algorithm for 
specific problem. 
MHW 3
Text/Reference Books 
• Introduction to Algorithms, 2nd Edition, Cormen, Leiserson, Rivest, 
and Stein (CLRS), MIT Press, (2001). 
• Design and Analysis of Algorithm by SartajSahni and Ellis Horwitz 
• Data Structures and Algorithm Analysis in C++, 3rd Ed., Mark Allen 
Weiss, Addison Wesley, (2006). 
• Data Structures (Special Indian Edition) (Schaum’s Outline Series), 
Lipschutz&Pai (Paperback) 
MHW 4
Algorithms 
Data Structure and Algorithms 
MHW 5
Outlines 
• Defining Algorithm 
• Understanding Algorithm 
• Analysis framework 
• Time and space complexity 
• Efficiency of Algorithm 
• Worst case 
• Best case 
• Average case 
• Asymptotic Notations 
• Big ‘Oh’ Notation (O) 
• Omega Notation (Ω) 
• Theta Notation (Θ) 
MHW 6
Algorithms 
• “Algorithmic is more than the branch of computer science. It is the 
core of computer science, and, in all fairness, can be said to be 
relevant it most of science, business and technology”. 
• “In mathematics and computer science, an algorithm is a step-by-step 
procedure for calculations”. 
• An algorithm is an effective method expressed as a finite list of well-defined 
instructions for calculating a function. 
MHW 7
Understanding of Algorithm 
• An algorithm is a sequence of unambiguous instruction for solving a 
problem, for obtaining a required output for any legitimate input in a 
finite amount of time. 
Problem 
Algorithm 
Input Computer Output 
MHW 8
ALGORITHM DESIGN AND ANALYSIS PROCESS 
Understood the Problem 
Decide On: 
Computational Means, 
Exact vs Approx Solving, 
Data Structures Algo 
Design Techniques 
Design the Algorithm 
Prove Correctness 
Analyze the Algorithm 
Code the Algorithm 
MHW 9
ANALYSIS FRAME WORK 
• There are two kinds of efficiency 
• Time efficiency - indicates how fast an algorithm in question runs. 
• Space efficiency - deals with the extra space the algorithm requires. 
MHW 10
MEASURING AN INPUT SIZE 
• An algorithm's efficiency as a function of some parameter n indicating the algorithm's 
input size. 
• In most cases, selecting such a parameter is quite straightforward. For example, it will be 
the size of the list for problems of sorting, searching, finding the list's smallest element, 
and most other problems dealing with lists. 
• There are situations, of course, where the choice of a parameter indicating an input size 
does matter. E.g. computing the product of two n-by-n matrices. 
• There are two natural measures of size for this problem. 
• The matrix order n. 
• The total number of elements N in the matrices being multiplied. 
• Since there is a simple formula relating these two measures, we can easily switch from 
one to the other, but the answer about an algorithm's efficiency will be qualitatively 
different depending on which of the two measures we use. 
• For such algorithms, computer scientists prefer measuring size by the number b of bits in 
the n's binary representation: b=[log2n] +1 
MHW 11
UNITS FOR MEASURING RUN TIME: 
• We can simply use some standard unit of time measurement-a second, a millisecond, and so on-to 
measure the running time of a program implementing the algorithm. 
• There are obvious drawbacks to such an approach. They are 
• Dependence on the speed of a particular computer 
• Dependence on the quality of a program implementing the algorithm 
• The compiler used in generating the machine code 
• The difficulty of clocking the actual running time of the program. 
• Since we are in need to measure algorithm efficiency, we should have a metric that does not 
depend on these extraneous factors. 
• One possible approach is to count the number of times each of the algorithm's operations is 
executed. This approach is both difficult and unnecessary. 
• The main objective is to identify the most important operation of the algorithm, called the basic 
operation, the operation contributing the most to the total running time, and compute the 
number of times the basic operation is executed. 
• As a rule, it is not difficult to identify the basic operation of an algorithm. 
MHW 12
WORST CASE, BEST CASE AND AVERAGE CASE 
EFFICIENCES 
• Worst case efficiency: 
• The worst-case efficiency of an algorithm is its efficiency for the worst-case input of size n, 
which is an input (or inputs) of size n for which the algorithm runs the longest among all 
possible inputs of that size. Cworst(n) = n. 
• Best case Efficiency 
• The best-case efficiency of an algorithm is its efficiency for the best-case input of size n, 
which is an input (or inputs) of size n for which the algorithm runs the fastest among all 
possible inputs of that size. 
• We can analyze the best case efficiency as follows: 
• First, determine the kind of inputs for which the count C (n) will be the smallest among all possible 
inputs of size n. 
• Note: the best case does not mean the smallest input; it means the input of size n for which the algorithm runs the fastest. 
• Then determine the value of C (n) on these most convenient inputs. Example: for sequential 
search, best-case inputs will be lists of size n with their first elements equal to a search key; 
accordingly, Cbest(n) = 1. 
MHW 13
WORST CASE, BEST CASE AND AVERAGE CASE 
EFFICIENCES 
• Average case efficiency 
• It yields the information about an algorithm or algorithm‘s behaviour on a 
―typical‖ and ―random‖ input. 
• To analyze the algorithm's average-case efficiency, we must make some 
assumptions about possible inputs of size n. 
• The investigation of the average case efficiency is considerably more difficult 
than investigation of the worst case and best case efficiency. 
• It involves dividing all instances of size n into several classes so that for each 
instance of the class the number of times the algorithm's basic operation is 
executed is the same. 
• Then a probability distribution of inputs needs to be obtained or assumed so 
that the expected value of the basic operation's count can then be derived. 
MHW 14
Asymptotic Notations 
• Step count is to compare time complexity of two programs that compute 
same function and also to predict the growth in run time as instance 
characteristics changes. Determining exact step count is difficult and not 
necessary also. Because the values are not exact quantities. We need only 
comparative statements like c1n2 ≤ tp(n) ≤ c2n2. 
• For example 
• Consider two programs with complexities c1n2 + c2n and c3n respectively. For small 
values of n, complexity depend upon values of c1, c2 and c3. But there will also be an 
n beyond which complexity of c3n is better than that of c1n2 + c2n. 
• This value of n is called break-even point. If this point is zero, c3n is always faster (or 
at least as fast). 
MHW 15
Common asymptotic functions 
MHW 16
Big ‘Oh’ Notation (O) 
• O(g(n)) = { f(n) : there exist positive constants c and n0 such that 0 ≤ 
f(n) ≤ cg(n) for all n ≥ n0 } 
• It is the upper bound of any function. Hence it denotes the worse 
case complexity of any algorithm. We can represent it graphically as 
MHW 17
Omega Notation (Ω) 
• Ω (g(n)) = { f(n) : there exist positive constants c and n0 such that 0 ≤ 
cg(n) ≤ f(n) for all n ≥ n0 } 
• It is the lower bound of any function. Hence it denotes the best case 
complexity of any algorithm. 
• Example: f(n) = 3n + 2 
• 3n + 2 > 3n for all n. 
• Hence f(n) = Ω(n) 
• Similarly we can solve all the examples specified under Big ‘Oh‘. 
MHW 19
Theta Notation (Θ) 
• Θ(g(n)) = {f(n) : there exist positive constants c1,c2 and n0 such that 
c1g(n) ≤f(n) ≤c2g(n) for all n ≥ n0 } 
• If f(n) = Θ(g(n)), all values of n right to n0 f(n) lies on or above c1g(n) 
and on or below c2g(n). Hence it is asymptotic tight bound for f(n). 
• Example f(n) = 3n + 2 
• f(n) = Θ(n) because f(n) = O(n) , n ≥ 2. 
• Similarly we can solve all examples specified under Big ‘Oh‘. 
MHW 20

More Related Content

What's hot

Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
Daffodil International University
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsAakash deep Singhal
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
Dr Geetha Mohan
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
smruti sarangi
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
YekoyeTigabuYeko
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
Swapnil Agrawal
 
Introduction to datastructure and algorithm
Introduction to datastructure and algorithmIntroduction to datastructure and algorithm
Introduction to datastructure and algorithm
Pratik Mota
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1Kumar
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming languageVasavi College of Engg
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSGayathri Gaayu
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
Madhu Bala
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
SHAKOOR AB
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
Dr Shashikant Athawale
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
Protap Mondal
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notationsEhtisham Ali
 
AD3251-Data Structures Design-Notes-Tree.pdf
AD3251-Data Structures  Design-Notes-Tree.pdfAD3251-Data Structures  Design-Notes-Tree.pdf
AD3251-Data Structures Design-Notes-Tree.pdf
Ramco Institute of Technology, Rajapalayam, Tamilnadu, India
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
Abhimanyu Mishra
 
Complexity Analysis
Complexity Analysis Complexity Analysis
Complexity Analysis
Shaista Qadir
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
Rajendran
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
Syed Zaid Irshad
 

What's hot (20)

Complexity analysis in Algorithms
Complexity analysis in AlgorithmsComplexity analysis in Algorithms
Complexity analysis in Algorithms
 
Lecture 2 data structures and algorithms
Lecture 2 data structures and algorithmsLecture 2 data structures and algorithms
Lecture 2 data structures and algorithms
 
Design and analysis of algorithms
Design and analysis of algorithmsDesign and analysis of algorithms
Design and analysis of algorithms
 
Daa notes 1
Daa notes 1Daa notes 1
Daa notes 1
 
Time complexity.ppt
Time complexity.pptTime complexity.ppt
Time complexity.ppt
 
Design and Analysis of Algorithms
Design and Analysis of AlgorithmsDesign and Analysis of Algorithms
Design and Analysis of Algorithms
 
Introduction to datastructure and algorithm
Introduction to datastructure and algorithmIntroduction to datastructure and algorithm
Introduction to datastructure and algorithm
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
 
Unit1 principle of programming language
Unit1 principle of programming languageUnit1 principle of programming language
Unit1 principle of programming language
 
DESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMSDESIGN AND ANALYSIS OF ALGORITHMS
DESIGN AND ANALYSIS OF ALGORITHMS
 
Greedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack ProblemGreedy Algorithm - Knapsack Problem
Greedy Algorithm - Knapsack Problem
 
Hashing Technique In Data Structures
Hashing Technique In Data StructuresHashing Technique In Data Structures
Hashing Technique In Data Structures
 
Asymptotic notation
Asymptotic notationAsymptotic notation
Asymptotic notation
 
Asymptotic Notation
Asymptotic NotationAsymptotic Notation
Asymptotic Notation
 
Asymptotic notations
Asymptotic notationsAsymptotic notations
Asymptotic notations
 
AD3251-Data Structures Design-Notes-Tree.pdf
AD3251-Data Structures  Design-Notes-Tree.pdfAD3251-Data Structures  Design-Notes-Tree.pdf
AD3251-Data Structures Design-Notes-Tree.pdf
 
Daa unit 1
Daa unit 1Daa unit 1
Daa unit 1
 
Complexity Analysis
Complexity Analysis Complexity Analysis
Complexity Analysis
 
Greedy algorithms
Greedy algorithmsGreedy algorithms
Greedy algorithms
 
Design and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptxDesign and Analysis of Algorithms.pptx
Design and Analysis of Algorithms.pptx
 

Viewers also liked

Analysis of software architectures
Analysis of software architecturesAnalysis of software architectures
Analysis of software architectures
Horia Constantin
 
Optimal placement of distributed power flow controller for loss reduction usi...
Optimal placement of distributed power flow controller for loss reduction usi...Optimal placement of distributed power flow controller for loss reduction usi...
Optimal placement of distributed power flow controller for loss reduction usi...
eSAT Journals
 
Chapter 6 Absolute Java
Chapter 6 Absolute JavaChapter 6 Absolute Java
Chapter 6 Absolute Java
Shariq Alee
 
Design and analysis of algorithms - Abstract View
Design and analysis of algorithms - Abstract ViewDesign and analysis of algorithms - Abstract View
Design and analysis of algorithms - Abstract View
Waqas Nawaz
 
Layered Software Architecture
Layered Software ArchitectureLayered Software Architecture
Layered Software Architecture
Lars-Erik Kindblad
 

Viewers also liked (6)

Analysis of software architectures
Analysis of software architecturesAnalysis of software architectures
Analysis of software architectures
 
Optimal placement of distributed power flow controller for loss reduction usi...
Optimal placement of distributed power flow controller for loss reduction usi...Optimal placement of distributed power flow controller for loss reduction usi...
Optimal placement of distributed power flow controller for loss reduction usi...
 
Chapter 6 Absolute Java
Chapter 6 Absolute JavaChapter 6 Absolute Java
Chapter 6 Absolute Java
 
Design and analysis of algorithms - Abstract View
Design and analysis of algorithms - Abstract ViewDesign and analysis of algorithms - Abstract View
Design and analysis of algorithms - Abstract View
 
Token03
Token03Token03
Token03
 
Layered Software Architecture
Layered Software ArchitectureLayered Software Architecture
Layered Software Architecture
 

Similar to Data Structures - Lecture 1 [introduction]

Slides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdfSlides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdf
Vijayraj799513
 
Chapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptChapter1.1 Introduction.ppt
Chapter1.1 Introduction.ppt
Tekle12
 
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.pptChapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Tekle12
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
AntareepMajumder
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
rajesshs31r
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
rajesshs31r
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
jinkhatima
 
Algorithms
Algorithms Algorithms
Algorithms
yashodhaHR2
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
MemMem25
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
Afaq Mansoor Khan
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
RahikAhmed1
 
DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
RAJESH S
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
RAJESH S
 
Chap5 slides
Chap5 slidesChap5 slides
Chap5 slides
BaliThorat1
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
Tribhuvan University
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
Bulbul Agrawal
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
jehan1987
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
iqbalphy1
 
Segment_1_New computer algorithm for cse.pptx
Segment_1_New computer algorithm for cse.pptxSegment_1_New computer algorithm for cse.pptx
Segment_1_New computer algorithm for cse.pptx
fahmidasetu
 

Similar to Data Structures - Lecture 1 [introduction] (20)

Slides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdfSlides [DAA] Unit 2 Ch 2.pdf
Slides [DAA] Unit 2 Ch 2.pdf
 
Chapter1.1 Introduction.ppt
Chapter1.1 Introduction.pptChapter1.1 Introduction.ppt
Chapter1.1 Introduction.ppt
 
Chapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.pptChapter1.1 Introduction to design and analysis of algorithm.ppt
Chapter1.1 Introduction to design and analysis of algorithm.ppt
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_I_25-07-2022_Fu...
 
Design Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptxDesign Analysis of Alogorithm 1 ppt 2024.pptx
Design Analysis of Alogorithm 1 ppt 2024.pptx
 
Analysis of Algorithm full version 2024.pptx
Analysis of Algorithm  full version  2024.pptxAnalysis of Algorithm  full version  2024.pptx
Analysis of Algorithm full version 2024.pptx
 
Unit 1, ADA.pptx
Unit 1, ADA.pptxUnit 1, ADA.pptx
Unit 1, ADA.pptx
 
Algorithms
Algorithms Algorithms
Algorithms
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Searching Algorithms
Searching AlgorithmsSearching Algorithms
Searching Algorithms
 
2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx2. Introduction to Algorithm.pptx
2. Introduction to Algorithm.pptx
 
DAA 1 ppt.pptx
DAA 1 ppt.pptxDAA 1 ppt.pptx
DAA 1 ppt.pptx
 
DAA ppt.pptx
DAA ppt.pptxDAA ppt.pptx
DAA ppt.pptx
 
Chap5 slides
Chap5 slidesChap5 slides
Chap5 slides
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Analysis and Design of Algorithms
Analysis and Design of AlgorithmsAnalysis and Design of Algorithms
Analysis and Design of Algorithms
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
Analysis of algorithms
Analysis of algorithmsAnalysis of algorithms
Analysis of algorithms
 
Segment_1_New computer algorithm for cse.pptx
Segment_1_New computer algorithm for cse.pptxSegment_1_New computer algorithm for cse.pptx
Segment_1_New computer algorithm for cse.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 

More from Muhammad Hammad Waseem

[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
Muhammad Hammad Waseem
 
[ITP - Lecture 14] Recursion
[ITP - Lecture 14] Recursion[ITP - Lecture 14] Recursion
[ITP - Lecture 14] Recursion
Muhammad Hammad Waseem
 
[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers
Muhammad Hammad Waseem
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 09] Conditional Operator in C/C++
[ITP - Lecture 09] Conditional Operator in C/C++[ITP - Lecture 09] Conditional Operator in C/C++
[ITP - Lecture 09] Conditional Operator in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)
Muhammad Hammad Waseem
 
[ITP - Lecture 07] Comments in C/C++
[ITP - Lecture 07] Comments in C/C++[ITP - Lecture 07] Comments in C/C++
[ITP - Lecture 07] Comments in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
Muhammad Hammad Waseem
 
[ITP - Lecture 05] Datatypes
[ITP - Lecture 05] Datatypes[ITP - Lecture 05] Datatypes
[ITP - Lecture 05] Datatypes
Muhammad Hammad Waseem
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++
Muhammad Hammad Waseem
 
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
Muhammad Hammad Waseem
 
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
Muhammad Hammad Waseem
 
[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance
Muhammad Hammad Waseem
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
Muhammad Hammad Waseem
 
[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member
Muhammad Hammad Waseem
 

More from Muhammad Hammad Waseem (20)

[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++[ITP - Lecture 17] Strings in C/C++
[ITP - Lecture 17] Strings in C/C++
 
[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++[ITP - Lecture 16] Structures in C/C++
[ITP - Lecture 16] Structures in C/C++
 
[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types[ITP - Lecture 15] Arrays & its Types
[ITP - Lecture 15] Arrays & its Types
 
[ITP - Lecture 14] Recursion
[ITP - Lecture 14] Recursion[ITP - Lecture 14] Recursion
[ITP - Lecture 14] Recursion
 
[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers[ITP - Lecture 13] Introduction to Pointers
[ITP - Lecture 13] Introduction to Pointers
 
[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++[ITP - Lecture 12] Functions in C/C++
[ITP - Lecture 12] Functions in C/C++
 
[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++[ITP - Lecture 11] Loops in C/C++
[ITP - Lecture 11] Loops in C/C++
 
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
[ITP - Lecture 10] Switch Statement, Break and Continue Statement in C/C++
 
[ITP - Lecture 09] Conditional Operator in C/C++
[ITP - Lecture 09] Conditional Operator in C/C++[ITP - Lecture 09] Conditional Operator in C/C++
[ITP - Lecture 09] Conditional Operator in C/C++
 
[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)[ITP - Lecture 08] Decision Control Structures (If Statement)
[ITP - Lecture 08] Decision Control Structures (If Statement)
 
[ITP - Lecture 07] Comments in C/C++
[ITP - Lecture 07] Comments in C/C++[ITP - Lecture 07] Comments in C/C++
[ITP - Lecture 07] Comments in C/C++
 
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
[ITP - Lecture 06] Operators, Arithmetic Expression and Order of Precedence
 
[ITP - Lecture 05] Datatypes
[ITP - Lecture 05] Datatypes[ITP - Lecture 05] Datatypes
[ITP - Lecture 05] Datatypes
 
[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++[ITP - Lecture 04] Variables and Constants in C/C++
[ITP - Lecture 04] Variables and Constants in C/C++
 
[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++[ITP - Lecture 03] Introduction to C/C++
[ITP - Lecture 03] Introduction to C/C++
 
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
[ITP - Lecture 02] Steps to Create Program & Approaches of Programming
 
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
[ITP - Lecture 01] Introduction to Programming & Different Programming Languages
 
[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance[OOP - Lec 20,21] Inheritance
[OOP - Lec 20,21] Inheritance
 
[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions[OOP - Lec 19] Static Member Functions
[OOP - Lec 19] Static Member Functions
 
[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member[OOP - Lec 18] Static Data Member
[OOP - Lec 18] Static Data Member
 

Recently uploaded

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
Atul Kumar Singh
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
Thiyagu K
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
MIRIAMSALINAS13
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
JosvitaDsouza2
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
Excellence Foundation for South Sudan
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 

Recently uploaded (20)

Language Across the Curriculm LAC B.Ed.
Language Across the  Curriculm LAC B.Ed.Language Across the  Curriculm LAC B.Ed.
Language Across the Curriculm LAC B.Ed.
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Unit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdfUnit 8 - Information and Communication Technology (Paper I).pdf
Unit 8 - Information and Communication Technology (Paper I).pdf
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXXPhrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
Phrasal Verbs.XXXXXXXXXXXXXXXXXXXXXXXXXX
 
1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx1.4 modern child centered education - mahatma gandhi-2.pptx
1.4 modern child centered education - mahatma gandhi-2.pptx
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
Introduction to Quality Improvement Essentials
Introduction to Quality Improvement EssentialsIntroduction to Quality Improvement Essentials
Introduction to Quality Improvement Essentials
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 

Data Structures - Lecture 1 [introduction]

  • 1. Data Structures and Algorithms Introduction Muhammad Hammad Waseem m.hammad.wasim@gmail.com
  • 2. Course Outlines • Asymptotic and Algorithm Analysis • Complexity Analysis of Algorithms • Abstract Lists and Implementations • Arrays • Linked Lists, Doubly Linked Lists • Stacks • Queues, Priority Queues, DE-queues, • Trees, Binary Search Trees, B-Trees, Balanced Search Trees, • Graph and Direct Acyclic Graph Algorithms, • Sorting Algorithms: Bubble Sort, Quick Sort, Merge Sort, Heap sort, • Minimum spanning trees, Shortest Path Problems, • Hashing, Chained Hash Tables, Double Hashing. MHW 2
  • 3. Course Objective • Enable the students to understand various ways to organize data, • Understand algorithm to manipulate data, • Use analyses compare various data structure and algorithms, • Select, apply and implement relevant data structure and algorithm for specific problem. MHW 3
  • 4. Text/Reference Books • Introduction to Algorithms, 2nd Edition, Cormen, Leiserson, Rivest, and Stein (CLRS), MIT Press, (2001). • Design and Analysis of Algorithm by SartajSahni and Ellis Horwitz • Data Structures and Algorithm Analysis in C++, 3rd Ed., Mark Allen Weiss, Addison Wesley, (2006). • Data Structures (Special Indian Edition) (Schaum’s Outline Series), Lipschutz&Pai (Paperback) MHW 4
  • 5. Algorithms Data Structure and Algorithms MHW 5
  • 6. Outlines • Defining Algorithm • Understanding Algorithm • Analysis framework • Time and space complexity • Efficiency of Algorithm • Worst case • Best case • Average case • Asymptotic Notations • Big ‘Oh’ Notation (O) • Omega Notation (Ω) • Theta Notation (Θ) MHW 6
  • 7. Algorithms • “Algorithmic is more than the branch of computer science. It is the core of computer science, and, in all fairness, can be said to be relevant it most of science, business and technology”. • “In mathematics and computer science, an algorithm is a step-by-step procedure for calculations”. • An algorithm is an effective method expressed as a finite list of well-defined instructions for calculating a function. MHW 7
  • 8. Understanding of Algorithm • An algorithm is a sequence of unambiguous instruction for solving a problem, for obtaining a required output for any legitimate input in a finite amount of time. Problem Algorithm Input Computer Output MHW 8
  • 9. ALGORITHM DESIGN AND ANALYSIS PROCESS Understood the Problem Decide On: Computational Means, Exact vs Approx Solving, Data Structures Algo Design Techniques Design the Algorithm Prove Correctness Analyze the Algorithm Code the Algorithm MHW 9
  • 10. ANALYSIS FRAME WORK • There are two kinds of efficiency • Time efficiency - indicates how fast an algorithm in question runs. • Space efficiency - deals with the extra space the algorithm requires. MHW 10
  • 11. MEASURING AN INPUT SIZE • An algorithm's efficiency as a function of some parameter n indicating the algorithm's input size. • In most cases, selecting such a parameter is quite straightforward. For example, it will be the size of the list for problems of sorting, searching, finding the list's smallest element, and most other problems dealing with lists. • There are situations, of course, where the choice of a parameter indicating an input size does matter. E.g. computing the product of two n-by-n matrices. • There are two natural measures of size for this problem. • The matrix order n. • The total number of elements N in the matrices being multiplied. • Since there is a simple formula relating these two measures, we can easily switch from one to the other, but the answer about an algorithm's efficiency will be qualitatively different depending on which of the two measures we use. • For such algorithms, computer scientists prefer measuring size by the number b of bits in the n's binary representation: b=[log2n] +1 MHW 11
  • 12. UNITS FOR MEASURING RUN TIME: • We can simply use some standard unit of time measurement-a second, a millisecond, and so on-to measure the running time of a program implementing the algorithm. • There are obvious drawbacks to such an approach. They are • Dependence on the speed of a particular computer • Dependence on the quality of a program implementing the algorithm • The compiler used in generating the machine code • The difficulty of clocking the actual running time of the program. • Since we are in need to measure algorithm efficiency, we should have a metric that does not depend on these extraneous factors. • One possible approach is to count the number of times each of the algorithm's operations is executed. This approach is both difficult and unnecessary. • The main objective is to identify the most important operation of the algorithm, called the basic operation, the operation contributing the most to the total running time, and compute the number of times the basic operation is executed. • As a rule, it is not difficult to identify the basic operation of an algorithm. MHW 12
  • 13. WORST CASE, BEST CASE AND AVERAGE CASE EFFICIENCES • Worst case efficiency: • The worst-case efficiency of an algorithm is its efficiency for the worst-case input of size n, which is an input (or inputs) of size n for which the algorithm runs the longest among all possible inputs of that size. Cworst(n) = n. • Best case Efficiency • The best-case efficiency of an algorithm is its efficiency for the best-case input of size n, which is an input (or inputs) of size n for which the algorithm runs the fastest among all possible inputs of that size. • We can analyze the best case efficiency as follows: • First, determine the kind of inputs for which the count C (n) will be the smallest among all possible inputs of size n. • Note: the best case does not mean the smallest input; it means the input of size n for which the algorithm runs the fastest. • Then determine the value of C (n) on these most convenient inputs. Example: for sequential search, best-case inputs will be lists of size n with their first elements equal to a search key; accordingly, Cbest(n) = 1. MHW 13
  • 14. WORST CASE, BEST CASE AND AVERAGE CASE EFFICIENCES • Average case efficiency • It yields the information about an algorithm or algorithm‘s behaviour on a ―typical‖ and ―random‖ input. • To analyze the algorithm's average-case efficiency, we must make some assumptions about possible inputs of size n. • The investigation of the average case efficiency is considerably more difficult than investigation of the worst case and best case efficiency. • It involves dividing all instances of size n into several classes so that for each instance of the class the number of times the algorithm's basic operation is executed is the same. • Then a probability distribution of inputs needs to be obtained or assumed so that the expected value of the basic operation's count can then be derived. MHW 14
  • 15. Asymptotic Notations • Step count is to compare time complexity of two programs that compute same function and also to predict the growth in run time as instance characteristics changes. Determining exact step count is difficult and not necessary also. Because the values are not exact quantities. We need only comparative statements like c1n2 ≤ tp(n) ≤ c2n2. • For example • Consider two programs with complexities c1n2 + c2n and c3n respectively. For small values of n, complexity depend upon values of c1, c2 and c3. But there will also be an n beyond which complexity of c3n is better than that of c1n2 + c2n. • This value of n is called break-even point. If this point is zero, c3n is always faster (or at least as fast). MHW 15
  • 17. Big ‘Oh’ Notation (O) • O(g(n)) = { f(n) : there exist positive constants c and n0 such that 0 ≤ f(n) ≤ cg(n) for all n ≥ n0 } • It is the upper bound of any function. Hence it denotes the worse case complexity of any algorithm. We can represent it graphically as MHW 17
  • 18. Omega Notation (Ω) • Ω (g(n)) = { f(n) : there exist positive constants c and n0 such that 0 ≤ cg(n) ≤ f(n) for all n ≥ n0 } • It is the lower bound of any function. Hence it denotes the best case complexity of any algorithm. • Example: f(n) = 3n + 2 • 3n + 2 > 3n for all n. • Hence f(n) = Ω(n) • Similarly we can solve all the examples specified under Big ‘Oh‘. MHW 19
  • 19. Theta Notation (Θ) • Θ(g(n)) = {f(n) : there exist positive constants c1,c2 and n0 such that c1g(n) ≤f(n) ≤c2g(n) for all n ≥ n0 } • If f(n) = Θ(g(n)), all values of n right to n0 f(n) lies on or above c1g(n) and on or below c2g(n). Hence it is asymptotic tight bound for f(n). • Example f(n) = 3n + 2 • f(n) = Θ(n) because f(n) = O(n) , n ≥ 2. • Similarly we can solve all examples specified under Big ‘Oh‘. MHW 20