SlideShare a Scribd company logo
ADSA- ADVANCED DATA STRUCTURES AND
ALGORITHMS (SEM-IV)
OUTLINE
Course Objectives
Course Outcome
Teaching Scheme
Modes of Assessment / Evaluation
Syllabus
Experiment List
Research Opportunities
Course Objectives:
The course intends to provide concrete implementations and
manipulation of discrete structures and their use in design and
analysis of non-trivial algorithms for a given computational task by
teaching the students fundamentals of Algorithms and Data
Structures.
Course Outcomes:
students will be able to:
MODES OF CONTINUOS ASSESSMENT /
EVALUATION
ISE: In-Semester Examination
IE: Innovative Examination
ESE: End Semester Examination
INNOVATIVE EXAMINATION
 This examination included in the Syllabus for 20 Marks
 Purpose is to evaluate student w.r.t understanding the
Subject concepts and its use to designs small applications.
 In Innovative Practice Students in a group or individually can
identify and implement given/self identified problem
definition.
 During the Semester Submission Small Report and
Presentation of IE needs to be Submitted and presented the
same during Oral Examination
RESEARCH OPPORTUNITIES
1. Search engine for data structures
2. Phone directory application using doubly-linked
lists
3. Spatial indexing with quadtrees
4. Graph-based projects on data structures
5. Stack-based text editor
MODULE -1
COMPLEXITY ANALYSIS
• Time & Space Complexity of Algorithms
• Importance of Efficient Algorithms
• Calculating time complexity of operations on data
structures (insert, delete, search, display)
• Total= 4 hrs
Time & Space Complexity
 Time complexity of an algorithm signifies the total time required by the program to
run till its completion.
 The time complexity of algorithms is most commonly expressed using the big O
notation. It's an asymptotic notation to represent the time complexity.
 Time Complexity is most commonly estimated by counting the number of elementary
steps performed by any algorithm to finish execution. Like in the example above, for
the first code the loop will run n number of times, so the time complexity will
be n atleast and as the value of n will increase the time taken will also increase.
 While for the second code, time complexity is constant, because it will never be
dependent on the value of n, it will always give the result in 1 step.
Algorithm Analysis
The algorithm can be analyzed in two levels, i.e., first is before creating the
algorithm, and second is after creating the algorithm. The following are the two
analysis of an algorithm:
Priori Analysis: Here, priori analysis is the theoretical analysis of an algorithm
which is done before implementing the algorithm. Various factors can be
considered before implementing the algorithm like processor speed, which has
no effect on the implementation part.
Posterior Analysis: Here, posterior analysis is a practical analysis of an
algorithm. The practical analysis is achieved by implementing the algorithm
using any programming language. This analysis basically evaluate that how
much running time and space taken by the algorithm.
Performance Analysis of an algorithm
Performance analysis of an algorithm is the process of calculating space and time
required by that algorithm.
Performance analysis of an algorithm is performed by using the following measures...
1. Space required to complete the task of that algorithm (Space Complexity). It includes
program space and data space.
2. Time required to complete the task of that algorithm (Time Complexity)
What is Time complexity?
The time complexity of an algorithm is the total amount of time required by an algorithm to
complete its execution. The running time of an algorithm depends upon the following...
1. Whether it is running on Single processor machine or Multi processor machine.
2. Whether it is a 32 bit machine or 64 bit machine.
3. Read and Write speed of the machine.
4. The amount of time required by an algorithm to perform Arithmetic operations, logical
operations, return value and assignment operations etc.,
5. Input data
Example
Consider the following piece of code..
int sum(int A[], int n)
{ int sum = 0, i; for(i = 0; i < n; i++)
sum = sum + A[i];
return sum;
}
For the above code, time complexity can be calculated as follows
Types of Algorithms
1. Search Algorithm
 Linear Search
 Binary Search
2. Sort Algorithm
 Bubble Sort
 Selection Sort
 Insertion Sort
 Merge Sort
 Quick Sort
 Heap Sort
Linear Search
It is one of the most simple and straightforward search
algorithms. In this, you need to traverse the entire list and keep
comparing the current element with the target element. If a
match is found, you can stop the search else continue.
Complexity Analysis
Time Complexity
•Best case - O(1)
The best occurs when the target element is found at the
beginning of the list/array. Since only one comparison is made,
the time complexity is O(1).
Example -
Array A[] = {3,4,0,9,8}
Target element = 3
Here, the target is found at A[0].
•Worst-case - O(n), where n is the size of the list/array.
The worst-case occurs when the target element is found at the end of the list or is
not present in the list/array. Since you need to traverse the entire list, the time
complexity is O(n), as n comparisons are needed.
•Average case - O(n)
The average case complexity of the linear search is also O(n).
Space Complexity
The space complexity of the linear search is O(1), as we don't need any auxiliary
space for the algorithm.
Binary Search
It is a divide and conquers algorithm in which we compare the target element with the
middle element of the list. If they are equal, then it implies that the target is found at the
middle position; else, we reduce the search space by half, i.e. apply binary search on
either of the left and right halves of the list depending upon whether target<middle
element or target>middle element. We continue this until a match is found or the size of
the array reaches 1.
Time Complexity
•Best case - O(1)
The best-case occurs when the target element is found in the middle of the
original list/array. Since only one comparison is needed, the time complexity is
O(1).
•Worst-case - O(logn)
The worst occurs when the algorithm keeps on searching for the target element
until the size of the array reduces to 1. Since the number of comparisons
required is logn, the time complexity is O(logn).
Binary Search
•Average case - O(logn)
Binary search has an average-case complexity of O(long).
Space Complexity
Since no extra space is needed, the space complexity of the binary search is
O(1).

More Related Content

Similar to ADSA orientation.pptx

Ds
DsDs
Unit 2 Modeling of Programs A function maps inputs to out.docx
Unit 2 Modeling of Programs A function maps inputs to out.docxUnit 2 Modeling of Programs A function maps inputs to out.docx
Unit 2 Modeling of Programs A function maps inputs to out.docx
dickonsondorris
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Ferdin Joe John Joseph PhD
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
SayanSen36
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
ssuserb7c8b8
 
Study on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortStudy on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining Sort
IRJET Journal
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
irdginfo
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
SayedMohdAsim2
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
racha49
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
SamridhiGulati4
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
BhargaviDalal4
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
Koteswari Kasireddy
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
Koteswari Kasireddy
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
Jabs6
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
NavneetSandhu0
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
Computer Hardware & Trouble shooting
 
Binary Sort
Binary SortBinary Sort
Binary Sort
Love Arora
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
ishan743441
 
Introduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxIntroduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptx
esuEthopi
 
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdfADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
RGPV De Bunkers
 

Similar to ADSA orientation.pptx (20)

Ds
DsDs
Ds
 
Unit 2 Modeling of Programs A function maps inputs to out.docx
Unit 2 Modeling of Programs A function maps inputs to out.docxUnit 2 Modeling of Programs A function maps inputs to out.docx
Unit 2 Modeling of Programs A function maps inputs to out.docx
 
Data Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm AnalysisData Structures and Algorithm - Week 11 - Algorithm Analysis
Data Structures and Algorithm - Week 11 - Algorithm Analysis
 
DA lecture 3.pptx
DA lecture 3.pptxDA lecture 3.pptx
DA lecture 3.pptx
 
Design and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit oneDesign and Analysis of Algorithm ppt for unit one
Design and Analysis of Algorithm ppt for unit one
 
Study on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining SortStudy on Sorting Algorithm and Position Determining Sort
Study on Sorting Algorithm and Position Determining Sort
 
9 big o-notation
9 big o-notation9 big o-notation
9 big o-notation
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
UNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.pptUNIT-1-PPTS-DAA.ppt
UNIT-1-PPTS-DAA.ppt
 
Introduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.pptIntroduction to Design Algorithm And Analysis.ppt
Introduction to Design Algorithm And Analysis.ppt
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Data structure introduction
Data structure introductionData structure introduction
Data structure introduction
 
Design & Analysis Of Algorithm
Design & Analysis Of AlgorithmDesign & Analysis Of Algorithm
Design & Analysis Of Algorithm
 
Binary Sort
Binary SortBinary Sort
Binary Sort
 
2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf2-Algorithms and Complexit data structurey.pdf
2-Algorithms and Complexit data structurey.pdf
 
Introduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptxIntroduction to Data Structure and algorithm.pptx
Introduction to Data Structure and algorithm.pptx
 
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdfADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
ADA Unit-1 Algorithmic Foundations Analysis, Design, and Efficiency.pdf
 

Recently uploaded

Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
Atif Razi
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
Prakhyath Rai
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
ycwu0509
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
MadhavJungKarki
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
mahaffeycheryld
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
Prakhyath Rai
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
AjmalKhan50578
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
aryanpankaj78
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
IJECEIAES
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
Kamal Acharya
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
UReason
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
ydzowc
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
ijaia
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
Divyanshu
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
ElakkiaU
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
bjmsejournal
 

Recently uploaded (20)

Applications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdfApplications of artificial Intelligence in Mechanical Engineering.pdf
Applications of artificial Intelligence in Mechanical Engineering.pdf
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...Software Engineering and Project Management - Introduction, Modeling Concepts...
Software Engineering and Project Management - Introduction, Modeling Concepts...
 
morris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdfmorris_worm_intro_and_source_code_analysis_.pdf
morris_worm_intro_and_source_code_analysis_.pdf
 
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
1FIDIC-CONSTRUCTION-CONTRACT-2ND-ED-2017-RED-BOOK.pdf
 
AI for Legal Research with applications, tools
AI for Legal Research with applications, toolsAI for Legal Research with applications, tools
AI for Legal Research with applications, tools
 
Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...Software Engineering and Project Management - Software Testing + Agile Method...
Software Engineering and Project Management - Software Testing + Agile Method...
 
Welding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdfWelding Metallurgy Ferrous Materials.pdf
Welding Metallurgy Ferrous Materials.pdf
 
Digital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptxDigital Twins Computer Networking Paper Presentation.pptx
Digital Twins Computer Networking Paper Presentation.pptx
 
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
Electric vehicle and photovoltaic advanced roles in enhancing the financial p...
 
Gas agency management system project report.pdf
Gas agency management system project report.pdfGas agency management system project report.pdf
Gas agency management system project report.pdf
 
Data Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason WebinarData Driven Maintenance | UReason Webinar
Data Driven Maintenance | UReason Webinar
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
原版制作(Humboldt毕业证书)柏林大学毕业证学位证一模一样
 
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODELDEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
DEEP LEARNING FOR SMART GRID INTRUSION DETECTION: A HYBRID CNN-LSTM-BASED MODEL
 
Null Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAMNull Bangalore | Pentesters Approach to AWS IAM
Null Bangalore | Pentesters Approach to AWS IAM
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
An Introduction to the Compiler Designss
An Introduction to the Compiler DesignssAn Introduction to the Compiler Designss
An Introduction to the Compiler Designss
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Design and optimization of ion propulsion drone
Design and optimization of ion propulsion droneDesign and optimization of ion propulsion drone
Design and optimization of ion propulsion drone
 

ADSA orientation.pptx

  • 1. ADSA- ADVANCED DATA STRUCTURES AND ALGORITHMS (SEM-IV)
  • 2. OUTLINE Course Objectives Course Outcome Teaching Scheme Modes of Assessment / Evaluation Syllabus Experiment List Research Opportunities
  • 3. Course Objectives: The course intends to provide concrete implementations and manipulation of discrete structures and their use in design and analysis of non-trivial algorithms for a given computational task by teaching the students fundamentals of Algorithms and Data Structures.
  • 5. MODES OF CONTINUOS ASSESSMENT / EVALUATION ISE: In-Semester Examination IE: Innovative Examination ESE: End Semester Examination
  • 6.
  • 7.
  • 8.
  • 9.
  • 10. INNOVATIVE EXAMINATION  This examination included in the Syllabus for 20 Marks  Purpose is to evaluate student w.r.t understanding the Subject concepts and its use to designs small applications.  In Innovative Practice Students in a group or individually can identify and implement given/self identified problem definition.  During the Semester Submission Small Report and Presentation of IE needs to be Submitted and presented the same during Oral Examination
  • 11. RESEARCH OPPORTUNITIES 1. Search engine for data structures 2. Phone directory application using doubly-linked lists 3. Spatial indexing with quadtrees 4. Graph-based projects on data structures 5. Stack-based text editor
  • 12. MODULE -1 COMPLEXITY ANALYSIS • Time & Space Complexity of Algorithms • Importance of Efficient Algorithms • Calculating time complexity of operations on data structures (insert, delete, search, display) • Total= 4 hrs
  • 13. Time & Space Complexity  Time complexity of an algorithm signifies the total time required by the program to run till its completion.  The time complexity of algorithms is most commonly expressed using the big O notation. It's an asymptotic notation to represent the time complexity.  Time Complexity is most commonly estimated by counting the number of elementary steps performed by any algorithm to finish execution. Like in the example above, for the first code the loop will run n number of times, so the time complexity will be n atleast and as the value of n will increase the time taken will also increase.  While for the second code, time complexity is constant, because it will never be dependent on the value of n, it will always give the result in 1 step.
  • 14. Algorithm Analysis The algorithm can be analyzed in two levels, i.e., first is before creating the algorithm, and second is after creating the algorithm. The following are the two analysis of an algorithm: Priori Analysis: Here, priori analysis is the theoretical analysis of an algorithm which is done before implementing the algorithm. Various factors can be considered before implementing the algorithm like processor speed, which has no effect on the implementation part. Posterior Analysis: Here, posterior analysis is a practical analysis of an algorithm. The practical analysis is achieved by implementing the algorithm using any programming language. This analysis basically evaluate that how much running time and space taken by the algorithm.
  • 15. Performance Analysis of an algorithm Performance analysis of an algorithm is the process of calculating space and time required by that algorithm. Performance analysis of an algorithm is performed by using the following measures... 1. Space required to complete the task of that algorithm (Space Complexity). It includes program space and data space. 2. Time required to complete the task of that algorithm (Time Complexity) What is Time complexity? The time complexity of an algorithm is the total amount of time required by an algorithm to complete its execution. The running time of an algorithm depends upon the following... 1. Whether it is running on Single processor machine or Multi processor machine. 2. Whether it is a 32 bit machine or 64 bit machine. 3. Read and Write speed of the machine. 4. The amount of time required by an algorithm to perform Arithmetic operations, logical operations, return value and assignment operations etc., 5. Input data
  • 16. Example Consider the following piece of code.. int sum(int A[], int n) { int sum = 0, i; for(i = 0; i < n; i++) sum = sum + A[i]; return sum; } For the above code, time complexity can be calculated as follows
  • 17. Types of Algorithms 1. Search Algorithm  Linear Search  Binary Search 2. Sort Algorithm  Bubble Sort  Selection Sort  Insertion Sort  Merge Sort  Quick Sort  Heap Sort
  • 18. Linear Search It is one of the most simple and straightforward search algorithms. In this, you need to traverse the entire list and keep comparing the current element with the target element. If a match is found, you can stop the search else continue. Complexity Analysis Time Complexity •Best case - O(1) The best occurs when the target element is found at the beginning of the list/array. Since only one comparison is made, the time complexity is O(1). Example - Array A[] = {3,4,0,9,8} Target element = 3 Here, the target is found at A[0].
  • 19. •Worst-case - O(n), where n is the size of the list/array. The worst-case occurs when the target element is found at the end of the list or is not present in the list/array. Since you need to traverse the entire list, the time complexity is O(n), as n comparisons are needed. •Average case - O(n) The average case complexity of the linear search is also O(n). Space Complexity The space complexity of the linear search is O(1), as we don't need any auxiliary space for the algorithm.
  • 20. Binary Search It is a divide and conquers algorithm in which we compare the target element with the middle element of the list. If they are equal, then it implies that the target is found at the middle position; else, we reduce the search space by half, i.e. apply binary search on either of the left and right halves of the list depending upon whether target<middle element or target>middle element. We continue this until a match is found or the size of the array reaches 1. Time Complexity •Best case - O(1) The best-case occurs when the target element is found in the middle of the original list/array. Since only one comparison is needed, the time complexity is O(1). •Worst-case - O(logn) The worst occurs when the algorithm keeps on searching for the target element until the size of the array reduces to 1. Since the number of comparisons required is logn, the time complexity is O(logn).
  • 21. Binary Search •Average case - O(logn) Binary search has an average-case complexity of O(long). Space Complexity Since no extra space is needed, the space complexity of the binary search is O(1).