SlideShare uma empresa Scribd logo
1 de 34
Advanced Data Structures
1
Contents
2
 Introduction Review of Basic
concepts
 What is Data Structure
 Basic Data Structures
 Data Structures Algorithms
 Asymptotic Analysis of Recurrences
 The Substitution method
Introduction
Data Structure:
Data Structure is a way to store and
organize data so that it can be used efficiently.
Data Structures are used to store and manage data in an
efficient and organised way for faster and easy access and
modification of Data.
3
Review of basic concepts
• Variables
• Data types
• Data structures
• Classification of data structure
• Different operations on data structures
• Algorithm
• Why the analysis of algorithms
• Goal of the analysis of algorithms
• What is running time analysis
• How to compare algorithms
• Types of analysis
4
Classification of data structure
5
Basic data structures
• Array.
• Linked list.
• Stack.
• Queue.
• Graph.
• Tree.
• Hash Table.
6
Hashing
• Hashing is a technique to convert a range of
key values into a range of indexes of an array.
• Range of key values can be obtained by using
modulo operator
7
Hashing Algorithm:
• A hash algorithm is a function that converts a
data string into a numeric string output of fixed
length
• The output string is generally much smaller
than the original data
• Two of the most common hash algorithms are
the MD5 Message-Digest Algorithm5 and the
SHA – 1(Secure Hash Algorithm)
8
Hash Table
• Is a data structure used to store keys/value
pairs
• It uses hash function to compute an index into
an array in which an element will be inserted or
searched
• By using a good hash function, hashing can
work well
9
Different operations on Data structures
The basic operations that are performed on data structures are as follows:
• Insertion: Insertion means addition of a new data element in a data
structure.
• Deletion: Deletion means removal of a data element from a data
structure if it is found.
Searching: Searching involves searching for the specified data element
in a data structure.
• Traversal: Traversal of a data structure means processing all the data
elements present in it.
10
Continue…
Following two are special operations:
• Sorting: Arranging data elements of a data structure in a specified order
is called sorting.
• Merging: Combining elements of two similar data structures to form a
new data structure of the same type, is called merging
11
Abstract Data Types (ADTs)
• Before defining abstract data types, let us consider the different view of system-
defined data types. We all know that, by default, all primitive data types (int, float,
etc.) support basic operations such as addition and subtraction. The system provides
the implementations for the primitive data types.
• For user-defined data types we also need to define operations. The implementation
for these operations can be done when we want to actually use them. That means, in
general, user defined data types are defined along with their operations.
• To simplify the process of solving problems, we combine the data structures with
their operations and we call this Abstract Data Types (ADTs). An ADT consists of
two parts:
• 1. Declaration of data
• 2. Declaration of operations
12
Continue…
• Commonly used ADTs include: Linked Lists, Stacks, Queues, Priority
Queues, Binary Trees, Dictionaries, Disjoint Sets (Union and Find),
Hash Tables, Graphs, and many others.
• For example, stack uses LIFO (Last-In-First-Out) mechanism while
storing the data in data structures. The last element inserted into the
stack is the first element that gets deleted.
• Common operations of it are: creating the stack, pushing an element
onto the stack, popping an element from stack, finding the current top
of the stack, finding number of elements in the stack, etc.
13
Algorithm:
An Algorithm is a sequence of steps to
solve a problem
or
Step by step process to find a solution for
a particular task
14
Algorithm Properties:
• Input
• Output
• Definiteness
• Finiteness
• Effectiveness
15
Process of Algorithm:
• How to design Algorithm
• Validation of Algorithm
• Analysis of algorithm
• Algorithm testing
Debugging
Profiling
Psuedo code
16
Time Complexity
• Time complexity of an algorithm represents the amount of time
required by the algorithm to run to completion.
• Time requirements can be defined as a numerical function
T(n), where T(n) can be measured as the number of steps,
provided each step consumes constant time
17
Space Complexity
• Space Complexity As the name suggests, it
means how much space or memory will the
algorithm take in terms of N, where N is very
large.
18
Asymptotic analysis
• Asymptotic analysis is input bound
• i.e., if there's no input to the algorithm, it is concluded to work
in a constant time. Other than the "input" all other factors are
considered constant.
19
Asymptotic analysis of an algorithm
• Asymptotic analysis is the process of calculating the running
time of an algorithm in mathematical units to find the “run-time
performance” of a program.
• Analyzing an algorithm helps measures the efficiency of your
program
• The goal is to determine the best case, worst case and
average case time required to execute a given task.
20
Finding the feasible solution :
21
.
• Usually, the time required by an algorithm falls under three
types −
• Best Case − Minimum time required for program execution.
• Average Case − Average time required for program execution.
• Worst Case − Maximum time required for program execution
22
Asymptotic Notations
Following are the commonly used asymptotic notations to calculate the
running time complexity of an algorithm.
• Ο Notation for Upper Bound – The worst case
• Ω Notation for Lower Bound – the best case
• θ Notation – the average case
23
Common Asymptotic Notations
constant − Ο(1)
logarithmic − Ο(log n)
linear − Ο(n)
n log n − Ο(n log n)
quadratic − Ο(n
2
)
cubic − Ο(n
3
)
polynomial − n
Ο(1)
exponential − 2
Ο(n)
24
Following is a list of some common asymptotic notations −
Big O notation
It’s the upper bound on the complexity of an algorithm.
Hence, it is used to denote the worst behavior of an algorithm.
25
Big O
Notation
26
Big Omega(Ω):
• Big Omega(Ω): Similar to Big O notation, the Ω notation is
used to define an asymptotic lower bound on the performance
of an algorithm. Hence, this is used for representing the best
case scenarios.
• The omega bound essentially means the minimum amount of
time that our algorithm will take to execute, irrespective of the
input.
27
28
Big theta notation
Big theta notation A tight bound on the behavior
of an algorithm, this notation defines the upper
and lower bounds for a function.
This is called a tight bound because we fix the
running time to within a constant factor above
and below.
29
Big theta
Notation
30
.
• Whenever we compare different algorithms for solving a
particular problem, we don’t just focus on the time
complexities. Space complexity is also an important aspect for
comparing different algorithms. Yes, it’s true that we have a lot
of memory available these days and hence, space is something
which can be compromised on.
• Choosing your algorithm wisely helps to optimize both time
and space.
31
The substitution method
• The substitution method for solving recurrence relations
consists of three steps: Guess the form of the solution. Verify by
induction. Solve for constants.
32
Iterative algorithm
• An iterative algorithm executes steps in iterations.
• It aims to find successive approximation in sequence to reach
a solution.
• They are most commonly used in linear programs where large
numbers of variables are involved.
• To be continued on the next class…
33
34

Mais conteúdo relacionado

Mais procurados

8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimization
Kumar
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
eShikshak
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
Kumar
 

Mais procurados (20)

Data Structures & Algorithms
Data Structures & AlgorithmsData Structures & Algorithms
Data Structures & Algorithms
 
external sorting
external sortingexternal sorting
external sorting
 
Data structures and algorithm analysis in java
Data structures and algorithm analysis in javaData structures and algorithm analysis in java
Data structures and algorithm analysis in java
 
Data Structures 7
Data Structures 7Data Structures 7
Data Structures 7
 
8 query processing and optimization
8 query processing and optimization8 query processing and optimization
8 query processing and optimization
 
Data Structures 6
Data Structures 6Data Structures 6
Data Structures 6
 
Lecture 01 Intro to DSA
Lecture 01 Intro to DSALecture 01 Intro to DSA
Lecture 01 Intro to DSA
 
Cost estimation for Query Optimization
Cost estimation for Query OptimizationCost estimation for Query Optimization
Cost estimation for Query Optimization
 
Linked list using Dynamic Memory Allocation
Linked list using Dynamic Memory AllocationLinked list using Dynamic Memory Allocation
Linked list using Dynamic Memory Allocation
 
Data Structures 8
Data Structures 8Data Structures 8
Data Structures 8
 
Elementary data structure
Elementary data structureElementary data structure
Elementary data structure
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Chapter15
Chapter15Chapter15
Chapter15
 
Basic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - NotesBasic of Data Structure - Data Structure - Notes
Basic of Data Structure - Data Structure - Notes
 
SQL: Query optimization in practice
SQL: Query optimization in practiceSQL: Query optimization in practice
SQL: Query optimization in practice
 
Introduction of data structure
Introduction of data structureIntroduction of data structure
Introduction of data structure
 
Data structure lecture 1
Data structure lecture 1Data structure lecture 1
Data structure lecture 1
 
Selection Sort with Improved Asymptotic Time Bounds
Selection Sort with Improved Asymptotic Time BoundsSelection Sort with Improved Asymptotic Time Bounds
Selection Sort with Improved Asymptotic Time Bounds
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Query processing-and-optimization
Query processing-and-optimizationQuery processing-and-optimization
Query processing-and-optimization
 

Semelhante a ADS Introduction

Semelhante a ADS Introduction (20)

UNIT 1.pptx
UNIT 1.pptxUNIT 1.pptx
UNIT 1.pptx
 
U nit i data structure-converted
U nit   i data structure-convertedU nit   i data structure-converted
U nit i data structure-converted
 
Algorithm analysis (All in one)
Algorithm analysis (All in one)Algorithm analysis (All in one)
Algorithm analysis (All in one)
 
algo 1.ppt
algo 1.pptalgo 1.ppt
algo 1.ppt
 
Intro_2.ppt
Intro_2.pptIntro_2.ppt
Intro_2.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Intro.ppt
Intro.pptIntro.ppt
Intro.ppt
 
Data structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdfData structures and algorithms Module-1.pdf
Data structures and algorithms Module-1.pdf
 
Algorithms and Data Structures
Algorithms and Data StructuresAlgorithms and Data Structures
Algorithms and Data Structures
 
Intro to Data Structure & Algorithms
Intro to Data Structure & AlgorithmsIntro to Data Structure & Algorithms
Intro to Data Structure & Algorithms
 
Unit 1 dsa
Unit 1 dsaUnit 1 dsa
Unit 1 dsa
 
RAJAT PROJECT.pptx
RAJAT PROJECT.pptxRAJAT PROJECT.pptx
RAJAT PROJECT.pptx
 
Lect1.pptx
Lect1.pptxLect1.pptx
Lect1.pptx
 
Chapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdfChapter 1 Introduction to Data Structures and Algorithms.pdf
Chapter 1 Introduction to Data Structures and Algorithms.pdf
 
Data structure and algorithm.
Data structure and algorithm. Data structure and algorithm.
Data structure and algorithm.
 
Data structure Unit-I Part A
Data structure Unit-I Part AData structure Unit-I Part A
Data structure Unit-I Part A
 
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
 
Chapter 1 Data structure.pptx
Chapter 1 Data structure.pptxChapter 1 Data structure.pptx
Chapter 1 Data structure.pptx
 
Basic terminologies & asymptotic notations
Basic terminologies & asymptotic notationsBasic terminologies & asymptotic notations
Basic terminologies & asymptotic notations
 
Chapter 1- IT.pptx
Chapter 1- IT.pptxChapter 1- IT.pptx
Chapter 1- IT.pptx
 

Último

The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
ssuserdda66b
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 

Último (20)

On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Food safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdfFood safety_Challenges food safety laboratories_.pdf
Food safety_Challenges food safety laboratories_.pdf
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Google Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptxGoogle Gemini An AI Revolution in Education.pptx
Google Gemini An AI Revolution in Education.pptx
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdfVishram Singh - Textbook of Anatomy  Upper Limb and Thorax.. Volume 1 (1).pdf
Vishram Singh - Textbook of Anatomy Upper Limb and Thorax.. Volume 1 (1).pdf
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
Single or Multiple melodic lines structure
Single or Multiple melodic lines structureSingle or Multiple melodic lines structure
Single or Multiple melodic lines structure
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)Accessible Digital Futures project (20/03/2024)
Accessible Digital Futures project (20/03/2024)
 

ADS Introduction

  • 2. Contents 2  Introduction Review of Basic concepts  What is Data Structure  Basic Data Structures  Data Structures Algorithms  Asymptotic Analysis of Recurrences  The Substitution method
  • 3. Introduction Data Structure: Data Structure is a way to store and organize data so that it can be used efficiently. Data Structures are used to store and manage data in an efficient and organised way for faster and easy access and modification of Data. 3
  • 4. Review of basic concepts • Variables • Data types • Data structures • Classification of data structure • Different operations on data structures • Algorithm • Why the analysis of algorithms • Goal of the analysis of algorithms • What is running time analysis • How to compare algorithms • Types of analysis 4
  • 6. Basic data structures • Array. • Linked list. • Stack. • Queue. • Graph. • Tree. • Hash Table. 6
  • 7. Hashing • Hashing is a technique to convert a range of key values into a range of indexes of an array. • Range of key values can be obtained by using modulo operator 7
  • 8. Hashing Algorithm: • A hash algorithm is a function that converts a data string into a numeric string output of fixed length • The output string is generally much smaller than the original data • Two of the most common hash algorithms are the MD5 Message-Digest Algorithm5 and the SHA – 1(Secure Hash Algorithm) 8
  • 9. Hash Table • Is a data structure used to store keys/value pairs • It uses hash function to compute an index into an array in which an element will be inserted or searched • By using a good hash function, hashing can work well 9
  • 10. Different operations on Data structures The basic operations that are performed on data structures are as follows: • Insertion: Insertion means addition of a new data element in a data structure. • Deletion: Deletion means removal of a data element from a data structure if it is found. Searching: Searching involves searching for the specified data element in a data structure. • Traversal: Traversal of a data structure means processing all the data elements present in it. 10
  • 11. Continue… Following two are special operations: • Sorting: Arranging data elements of a data structure in a specified order is called sorting. • Merging: Combining elements of two similar data structures to form a new data structure of the same type, is called merging 11
  • 12. Abstract Data Types (ADTs) • Before defining abstract data types, let us consider the different view of system- defined data types. We all know that, by default, all primitive data types (int, float, etc.) support basic operations such as addition and subtraction. The system provides the implementations for the primitive data types. • For user-defined data types we also need to define operations. The implementation for these operations can be done when we want to actually use them. That means, in general, user defined data types are defined along with their operations. • To simplify the process of solving problems, we combine the data structures with their operations and we call this Abstract Data Types (ADTs). An ADT consists of two parts: • 1. Declaration of data • 2. Declaration of operations 12
  • 13. Continue… • Commonly used ADTs include: Linked Lists, Stacks, Queues, Priority Queues, Binary Trees, Dictionaries, Disjoint Sets (Union and Find), Hash Tables, Graphs, and many others. • For example, stack uses LIFO (Last-In-First-Out) mechanism while storing the data in data structures. The last element inserted into the stack is the first element that gets deleted. • Common operations of it are: creating the stack, pushing an element onto the stack, popping an element from stack, finding the current top of the stack, finding number of elements in the stack, etc. 13
  • 14. Algorithm: An Algorithm is a sequence of steps to solve a problem or Step by step process to find a solution for a particular task 14
  • 15. Algorithm Properties: • Input • Output • Definiteness • Finiteness • Effectiveness 15
  • 16. Process of Algorithm: • How to design Algorithm • Validation of Algorithm • Analysis of algorithm • Algorithm testing Debugging Profiling Psuedo code 16
  • 17. Time Complexity • Time complexity of an algorithm represents the amount of time required by the algorithm to run to completion. • Time requirements can be defined as a numerical function T(n), where T(n) can be measured as the number of steps, provided each step consumes constant time 17
  • 18. Space Complexity • Space Complexity As the name suggests, it means how much space or memory will the algorithm take in terms of N, where N is very large. 18
  • 19. Asymptotic analysis • Asymptotic analysis is input bound • i.e., if there's no input to the algorithm, it is concluded to work in a constant time. Other than the "input" all other factors are considered constant. 19
  • 20. Asymptotic analysis of an algorithm • Asymptotic analysis is the process of calculating the running time of an algorithm in mathematical units to find the “run-time performance” of a program. • Analyzing an algorithm helps measures the efficiency of your program • The goal is to determine the best case, worst case and average case time required to execute a given task. 20
  • 21. Finding the feasible solution : 21
  • 22. . • Usually, the time required by an algorithm falls under three types − • Best Case − Minimum time required for program execution. • Average Case − Average time required for program execution. • Worst Case − Maximum time required for program execution 22
  • 23. Asymptotic Notations Following are the commonly used asymptotic notations to calculate the running time complexity of an algorithm. • Ο Notation for Upper Bound – The worst case • Ω Notation for Lower Bound – the best case • θ Notation – the average case 23
  • 24. Common Asymptotic Notations constant − Ο(1) logarithmic − Ο(log n) linear − Ο(n) n log n − Ο(n log n) quadratic − Ο(n 2 ) cubic − Ο(n 3 ) polynomial − n Ο(1) exponential − 2 Ο(n) 24 Following is a list of some common asymptotic notations −
  • 25. Big O notation It’s the upper bound on the complexity of an algorithm. Hence, it is used to denote the worst behavior of an algorithm. 25
  • 27. Big Omega(Ω): • Big Omega(Ω): Similar to Big O notation, the Ω notation is used to define an asymptotic lower bound on the performance of an algorithm. Hence, this is used for representing the best case scenarios. • The omega bound essentially means the minimum amount of time that our algorithm will take to execute, irrespective of the input. 27
  • 28. 28
  • 29. Big theta notation Big theta notation A tight bound on the behavior of an algorithm, this notation defines the upper and lower bounds for a function. This is called a tight bound because we fix the running time to within a constant factor above and below. 29
  • 31. . • Whenever we compare different algorithms for solving a particular problem, we don’t just focus on the time complexities. Space complexity is also an important aspect for comparing different algorithms. Yes, it’s true that we have a lot of memory available these days and hence, space is something which can be compromised on. • Choosing your algorithm wisely helps to optimize both time and space. 31
  • 32. The substitution method • The substitution method for solving recurrence relations consists of three steps: Guess the form of the solution. Verify by induction. Solve for constants. 32
  • 33. Iterative algorithm • An iterative algorithm executes steps in iterations. • It aims to find successive approximation in sequence to reach a solution. • They are most commonly used in linear programs where large numbers of variables are involved. • To be continued on the next class… 33
  • 34. 34