SlideShare a Scribd company logo
Warshall’s Algorithm
&
Dynamic Programming
BY
DEBARATI DAS ( CS-52)
Key Points OF Discussion
1
• FB vs Google+ (graph types)
• Transitive Closure
2
• Explanation of Warshall Algorithm
• Complexity Analysis
3
• Applications of Warshall Algorithm
FB Vs Google+
Transitive Closure
1
• What is Transitivity ?
• Express it in a graph :
2
• What is Transitive Closure ?
• Express as a Matrix :
• How can we find Transitive Closure of A
Graph ?
Finding Transitive Closure
• Involves searching for the shortest path
starting at every vertex.
• If you start at ith vertex, after traversal you
get columns containing 1 in the ith row.
• Clearly it has a disadvantage (?)
DFS
Implementation
• It involves finding the shortest path and
improving the estimate on the path every
single time, till its optimal.
• However, this fails in case of negative
cycles.
Basic Point of
The Warshall
Algorithm
Warshall Algorithm : Visitation
Example
Warshall Algorithm : Weighted
Example
Warshall Algorithm, brief
Complexity Analysis :
In this Bottom up Dynamic approach,
D0 -> 0
D1 -> n2 problems , every problem is a value in a cell.
n2xn where n2 denotes subproblems and n is no of matrices
So,total number of problems that need to be solved are n3
Therefore Time complexity is O(n3)
Space Complexity :
D1->D0
D2->D1
D3->D2
At any point of time you need two matrices so O(n2)
Applications of Warshall Algorithm
1. Shortest Path in Directed Graphs
2. Optimal Routing
3. Check if a graph is Bipartite
4. Pathfinder Networks
5. Inversion of Real Networks
(Gauss Jordan Method)
Key Questions
1
• What is the difference between D&C and DP ?
• What is Dynamic Programming ?
• Why is it called “Dynamic” ?
2
• What is Space Time Trade off ?
• How is it implemented by DP ?
• What are the applications of DP ?
• What is a non optimizable problem ?
3
• What is transitive Closure ?
• Warshall Algorithm discussion
Fibonacci Series : An illustration
fib(5)
fib(4) fib(3)
fib(3) fib(2) fib(2) fib(1)
fib(2) fib(1) fib(1) fib(0) fib(1) fib(0)
fib(1) fib(0)
6
5
21
3
4
Divide and Conquer vs D.P
 Clearly If We use Divide and Conquer, We face
OVER LAP.
 Mostly values are calculated again and again,
so even though access of function is O(1) , the
total time complexity is exponential or O(2n).
 INSTEAD if we used DP. We would store each
value in a table and access when required.
 DP Time complexity becomes O(n)
Why is it called “Dynamic
Programming” ?
Dynamic Programming : Basic Idea
 Avoid calculating the same thing twice by keeping a table of
known results, which we fill up as subinstances are solved.
 Dynamic programming is a bottom-up / top down technique
 Bottom up dynamic programming evaluates by computing all
function values in order, starting at lowest and using previously
computed values.
 Can MERGE SORT Be solved using DP ?
Ad

More Related Content

What's hot (20)

Network Security (Revised Syllabus) [QP / April - 2015]
Network Security (Revised Syllabus) [QP / April - 2015]Network Security (Revised Syllabus) [QP / April - 2015]
Network Security (Revised Syllabus) [QP / April - 2015]
Mumbai B.Sc.IT Study
 
[Question Paper] Network Security (Revised Syllabus) [October / 2012]
[Question Paper] Network Security (Revised Syllabus) [October / 2012][Question Paper] Network Security (Revised Syllabus) [October / 2012]
[Question Paper] Network Security (Revised Syllabus) [October / 2012]
Mumbai B.Sc.IT Study
 
Search
SearchSearch
Search
Vinay Salodkar
 
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
[Question Paper] Network Security (75:25 Pattern) [November / 2015]
[Question Paper] Network Security (75:25 Pattern) [November / 2015][Question Paper] Network Security (75:25 Pattern) [November / 2015]
[Question Paper] Network Security (75:25 Pattern) [November / 2015]
Mumbai B.Sc.IT Study
 
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
[Question Paper] Network Security (Revised Syllabus) [April / 2015]
[Question Paper] Network Security (Revised Syllabus) [April / 2015][Question Paper] Network Security (Revised Syllabus) [April / 2015]
[Question Paper] Network Security (Revised Syllabus) [April / 2015]
Mumbai B.Sc.IT Study
 
Network Security (Revised Syllabus) [QP / October - 2012]
Network Security (Revised Syllabus) [QP / October - 2012]Network Security (Revised Syllabus) [QP / October - 2012]
Network Security (Revised Syllabus) [QP / October - 2012]
Mumbai B.Sc.IT Study
 
Java and Data Structure (October - 2016) [Revised Course | Question Paper]
Java and Data Structure (October - 2016) [Revised Course | Question Paper]Java and Data Structure (October - 2016) [Revised Course | Question Paper]
Java and Data Structure (October - 2016) [Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
Breadth first search signed
Breadth first search signedBreadth first search signed
Breadth first search signed
AfshanKhan51
 
NP completeness
NP completenessNP completeness
NP completeness
Amrinder Arora
 
Network Security (Revised Syllabus) [QP / April - 2014]
Network Security (Revised Syllabus) [QP / April - 2014]Network Security (Revised Syllabus) [QP / April - 2014]
Network Security (Revised Syllabus) [QP / April - 2014]
Mumbai B.Sc.IT Study
 
Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...
Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...
Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...
Shin Kanouchi
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence
ilias ahmed
 
Complexity theory
Complexity theory Complexity theory
Complexity theory
Dr Shashikant Athawale
 
Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...
Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...
Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...
Mumbai B.Sc.IT Study
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
Kapil Dahal
 
Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
A small debate of power of randomness
A small debate of power of randomnessA small debate of power of randomness
A small debate of power of randomness
Abner Chih Yi Huang
 
[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...
[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...
[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...
Mumbai B.Sc.IT Study
 
Network Security (Revised Syllabus) [QP / April - 2015]
Network Security (Revised Syllabus) [QP / April - 2015]Network Security (Revised Syllabus) [QP / April - 2015]
Network Security (Revised Syllabus) [QP / April - 2015]
Mumbai B.Sc.IT Study
 
[Question Paper] Network Security (Revised Syllabus) [October / 2012]
[Question Paper] Network Security (Revised Syllabus) [October / 2012][Question Paper] Network Security (Revised Syllabus) [October / 2012]
[Question Paper] Network Security (Revised Syllabus) [October / 2012]
Mumbai B.Sc.IT Study
 
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (April - 2015) [IDOL - Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
[Question Paper] Network Security (75:25 Pattern) [November / 2015]
[Question Paper] Network Security (75:25 Pattern) [November / 2015][Question Paper] Network Security (75:25 Pattern) [November / 2015]
[Question Paper] Network Security (75:25 Pattern) [November / 2015]
Mumbai B.Sc.IT Study
 
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
B.Sc.IT: Semester - VI (May - 2018) [IDOL - Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
[Question Paper] Network Security (Revised Syllabus) [April / 2015]
[Question Paper] Network Security (Revised Syllabus) [April / 2015][Question Paper] Network Security (Revised Syllabus) [April / 2015]
[Question Paper] Network Security (Revised Syllabus) [April / 2015]
Mumbai B.Sc.IT Study
 
Network Security (Revised Syllabus) [QP / October - 2012]
Network Security (Revised Syllabus) [QP / October - 2012]Network Security (Revised Syllabus) [QP / October - 2012]
Network Security (Revised Syllabus) [QP / October - 2012]
Mumbai B.Sc.IT Study
 
Java and Data Structure (October - 2016) [Revised Course | Question Paper]
Java and Data Structure (October - 2016) [Revised Course | Question Paper]Java and Data Structure (October - 2016) [Revised Course | Question Paper]
Java and Data Structure (October - 2016) [Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
Breadth first search signed
Breadth first search signedBreadth first search signed
Breadth first search signed
AfshanKhan51
 
Network Security (Revised Syllabus) [QP / April - 2014]
Network Security (Revised Syllabus) [QP / April - 2014]Network Security (Revised Syllabus) [QP / April - 2014]
Network Security (Revised Syllabus) [QP / April - 2014]
Mumbai B.Sc.IT Study
 
Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...
Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...
Multi-Target Machine Translation with Multi-Synchronous Context-free Grammars...
Shin Kanouchi
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence
ilias ahmed
 
Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...
Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...
Digital Signals and Systems (December – 2017) [Question Paper | IDOL: Revised...
Mumbai B.Sc.IT Study
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
Kapil Dahal
 
Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Java and Data Structure (September - 2013) [Revised Course | Question Paper]
Mumbai B.Sc.IT Study
 
A small debate of power of randomness
A small debate of power of randomnessA small debate of power of randomness
A small debate of power of randomness
Abner Chih Yi Huang
 
[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...
[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...
[Question Paper] Fundamentals of Digital Computing (Revised Course) [April / ...
Mumbai B.Sc.IT Study
 

Viewers also liked (20)

Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
Muhammad Amjad Rana
 
Freeing India of “Divide & Rule”
Freeing India of “Divide & Rule” Freeing India of “Divide & Rule”
Freeing India of “Divide & Rule”
cvikash
 
Randomized Algorithms in Linear Algebra & the Column Subset Selection Problem
Randomized Algorithms in Linear Algebra & the Column Subset Selection ProblemRandomized Algorithms in Linear Algebra & the Column Subset Selection Problem
Randomized Algorithms in Linear Algebra & the Column Subset Selection Problem
Wei Xue
 
Chap08alg
Chap08algChap08alg
Chap08alg
Munkhchimeg
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
Rajendran
 
Load balancing
Load balancingLoad balancing
Load balancing
Ahmed Sherief El-Dakhakhny
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Melaku Bayih Demessie
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
BG Java EE Course
 
Greedyalgorithm
Greedyalgorithm Greedyalgorithm
Greedyalgorithm
Diksha Lad
 
Floyd Warshall algorithm easy way to compute - Malinga
Floyd Warshall algorithm easy way to compute - MalingaFloyd Warshall algorithm easy way to compute - Malinga
Floyd Warshall algorithm easy way to compute - Malinga
Malinga Perera
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Maher Alshammari
 
(floyd's algm)
(floyd's algm)(floyd's algm)
(floyd's algm)
Jothi Lakshmi
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
Yıldırım Tam
 
Solving The Shortest Path Tour Problem
Solving The Shortest Path Tour ProblemSolving The Shortest Path Tour Problem
Solving The Shortest Path Tour Problem
Nozir Shokirov
 
21 backtracking
21 backtracking21 backtracking
21 backtracking
Aparup Behera
 
Load Balancing with Apache
Load Balancing with ApacheLoad Balancing with Apache
Load Balancing with Apache
Bradley Holt
 
DP
DPDP
DP
Subba Oota
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
Krish_ver2
 
Subset sum problem Dynamic and Brute Force Approch
Subset sum problem Dynamic and Brute Force ApprochSubset sum problem Dynamic and Brute Force Approch
Subset sum problem Dynamic and Brute Force Approch
Ijlal Ijlal
 
Covering (Rules-based) Algorithm
Covering (Rules-based) AlgorithmCovering (Rules-based) Algorithm
Covering (Rules-based) Algorithm
ZHAO Sam
 
Freeing India of “Divide & Rule”
Freeing India of “Divide & Rule” Freeing India of “Divide & Rule”
Freeing India of “Divide & Rule”
cvikash
 
Randomized Algorithms in Linear Algebra & the Column Subset Selection Problem
Randomized Algorithms in Linear Algebra & the Column Subset Selection ProblemRandomized Algorithms in Linear Algebra & the Column Subset Selection Problem
Randomized Algorithms in Linear Algebra & the Column Subset Selection Problem
Wei Xue
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
Rajendran
 
Greedyalgorithm
Greedyalgorithm Greedyalgorithm
Greedyalgorithm
Diksha Lad
 
Floyd Warshall algorithm easy way to compute - Malinga
Floyd Warshall algorithm easy way to compute - MalingaFloyd Warshall algorithm easy way to compute - Malinga
Floyd Warshall algorithm easy way to compute - Malinga
Malinga Perera
 
Solving The Shortest Path Tour Problem
Solving The Shortest Path Tour ProblemSolving The Shortest Path Tour Problem
Solving The Shortest Path Tour Problem
Nozir Shokirov
 
Load Balancing with Apache
Load Balancing with ApacheLoad Balancing with Apache
Load Balancing with Apache
Bradley Holt
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
Krish_ver2
 
Subset sum problem Dynamic and Brute Force Approch
Subset sum problem Dynamic and Brute Force ApprochSubset sum problem Dynamic and Brute Force Approch
Subset sum problem Dynamic and Brute Force Approch
Ijlal Ijlal
 
Covering (Rules-based) Algorithm
Covering (Rules-based) AlgorithmCovering (Rules-based) Algorithm
Covering (Rules-based) Algorithm
ZHAO Sam
 
Ad

Similar to Class warshal2 (20)

8. Dynamic Prog _Warshall_Floyd Algorithm.pptx
8. Dynamic Prog _Warshall_Floyd Algorithm.pptx8. Dynamic Prog _Warshall_Floyd Algorithm.pptx
8. Dynamic Prog _Warshall_Floyd Algorithm.pptx
Suma Raj
 
Search algorithms for discrete optimization
Search algorithms for discrete optimizationSearch algorithms for discrete optimization
Search algorithms for discrete optimization
Sally Salem
 
Distributed computation and reconfiguration in actively dynamic networks
Distributed computation and reconfiguration in actively dynamic networksDistributed computation and reconfiguration in actively dynamic networks
Distributed computation and reconfiguration in actively dynamic networks
Peter Kos
 
Slides
SlidesSlides
Slides
xbj25kl
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
Yun-Yan Chi
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
iftakhar8
 
Lecture-12-CS345A-2023 of Design and Analysis
Lecture-12-CS345A-2023 of Design and AnalysisLecture-12-CS345A-2023 of Design and Analysis
Lecture-12-CS345A-2023 of Design and Analysis
ssuser9183b6
 
Deep learning
Deep learningDeep learning
Deep learning
Pratap Dangeti
 
The Factoring Dead: Preparing for the Cryptopocalypse
The Factoring Dead: Preparing for the CryptopocalypseThe Factoring Dead: Preparing for the Cryptopocalypse
The Factoring Dead: Preparing for the Cryptopocalypse
Alex Stamos
 
Online learning, Vowpal Wabbit and Hadoop
Online learning, Vowpal Wabbit and HadoopOnline learning, Vowpal Wabbit and Hadoop
Online learning, Vowpal Wabbit and Hadoop
Héloïse Nonne
 
Discrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
Discrete Logarithmic Problem- Basis of Elliptic Curve CryptosystemsDiscrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
Discrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
NIT Sikkim
 
AI - Backtracking vs Depth-First Search (DFS)
AI - Backtracking vs Depth-First Search (DFS)AI - Backtracking vs Depth-First Search (DFS)
AI - Backtracking vs Depth-First Search (DFS)
Johnnatan Messias
 
Shor's discrete logarithm quantum algorithm for elliptic curves
 Shor's discrete logarithm quantum algorithm for elliptic curves Shor's discrete logarithm quantum algorithm for elliptic curves
Shor's discrete logarithm quantum algorithm for elliptic curves
XequeMateShannon
 
gSpan algorithm
gSpan algorithmgSpan algorithm
gSpan algorithm
Sadik Mussah
 
gSpan algorithm
 gSpan algorithm gSpan algorithm
gSpan algorithm
Sadik Mussah
 
Topological Sort Algorithm.pptx
Topological Sort Algorithm.pptxTopological Sort Algorithm.pptx
Topological Sort Algorithm.pptx
MuhammadShafi89
 
Batch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptx
Batch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptxBatch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptx
Batch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptx
DhanushKumar610673
 
Unit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptx
Unit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptx
Unit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptx
trwdcn
 
GR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL Support
GR8Conf
 
Better DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseBetter DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-Eclipse
Andrew Eisenberg
 
8. Dynamic Prog _Warshall_Floyd Algorithm.pptx
8. Dynamic Prog _Warshall_Floyd Algorithm.pptx8. Dynamic Prog _Warshall_Floyd Algorithm.pptx
8. Dynamic Prog _Warshall_Floyd Algorithm.pptx
Suma Raj
 
Search algorithms for discrete optimization
Search algorithms for discrete optimizationSearch algorithms for discrete optimization
Search algorithms for discrete optimization
Sally Salem
 
Distributed computation and reconfiguration in actively dynamic networks
Distributed computation and reconfiguration in actively dynamic networksDistributed computation and reconfiguration in actively dynamic networks
Distributed computation and reconfiguration in actively dynamic networks
Peter Kos
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
Yun-Yan Chi
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
iftakhar8
 
Lecture-12-CS345A-2023 of Design and Analysis
Lecture-12-CS345A-2023 of Design and AnalysisLecture-12-CS345A-2023 of Design and Analysis
Lecture-12-CS345A-2023 of Design and Analysis
ssuser9183b6
 
The Factoring Dead: Preparing for the Cryptopocalypse
The Factoring Dead: Preparing for the CryptopocalypseThe Factoring Dead: Preparing for the Cryptopocalypse
The Factoring Dead: Preparing for the Cryptopocalypse
Alex Stamos
 
Online learning, Vowpal Wabbit and Hadoop
Online learning, Vowpal Wabbit and HadoopOnline learning, Vowpal Wabbit and Hadoop
Online learning, Vowpal Wabbit and Hadoop
Héloïse Nonne
 
Discrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
Discrete Logarithmic Problem- Basis of Elliptic Curve CryptosystemsDiscrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
Discrete Logarithmic Problem- Basis of Elliptic Curve Cryptosystems
NIT Sikkim
 
AI - Backtracking vs Depth-First Search (DFS)
AI - Backtracking vs Depth-First Search (DFS)AI - Backtracking vs Depth-First Search (DFS)
AI - Backtracking vs Depth-First Search (DFS)
Johnnatan Messias
 
Shor's discrete logarithm quantum algorithm for elliptic curves
 Shor's discrete logarithm quantum algorithm for elliptic curves Shor's discrete logarithm quantum algorithm for elliptic curves
Shor's discrete logarithm quantum algorithm for elliptic curves
XequeMateShannon
 
Topological Sort Algorithm.pptx
Topological Sort Algorithm.pptxTopological Sort Algorithm.pptx
Topological Sort Algorithm.pptx
MuhammadShafi89
 
Batch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptx
Batch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptxBatch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptx
Batch 5 DAaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaA.pptx
DhanushKumar610673
 
Unit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptx
Unit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptx
Unit 2 AI.pptxUnit 2 AI.pptxUnit 2 AI.pptx
trwdcn
 
GR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL Support
GR8Conf
 
Better DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseBetter DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-Eclipse
Andrew Eisenberg
 
Ad

More from Debarati Das (6)

Semantic Analysis of a C Program
Semantic Analysis of a C ProgramSemantic Analysis of a C Program
Semantic Analysis of a C Program
Debarati Das
 
Carnegie ppt
Carnegie pptCarnegie ppt
Carnegie ppt
Debarati Das
 
Quiz on Digital Logic and Combinatorial Circuits
Quiz on Digital Logic and Combinatorial CircuitsQuiz on Digital Logic and Combinatorial Circuits
Quiz on Digital Logic and Combinatorial Circuits
Debarati Das
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
Debarati Das
 
Binary Codes and Number System
Binary Codes and Number SystemBinary Codes and Number System
Binary Codes and Number System
Debarati Das
 
Lattices AND Hasse Diagrams
Lattices AND Hasse DiagramsLattices AND Hasse Diagrams
Lattices AND Hasse Diagrams
Debarati Das
 
Semantic Analysis of a C Program
Semantic Analysis of a C ProgramSemantic Analysis of a C Program
Semantic Analysis of a C Program
Debarati Das
 
Quiz on Digital Logic and Combinatorial Circuits
Quiz on Digital Logic and Combinatorial CircuitsQuiz on Digital Logic and Combinatorial Circuits
Quiz on Digital Logic and Combinatorial Circuits
Debarati Das
 
Binary Codes and Number System
Binary Codes and Number SystemBinary Codes and Number System
Binary Codes and Number System
Debarati Das
 
Lattices AND Hasse Diagrams
Lattices AND Hasse DiagramsLattices AND Hasse Diagrams
Lattices AND Hasse Diagrams
Debarati Das
 

Recently uploaded (20)

How to use nRF24L01 module with Arduino
How to use nRF24L01 module with ArduinoHow to use nRF24L01 module with Arduino
How to use nRF24L01 module with Arduino
CircuitDigest
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
Resistance measurement and cfd test on darpa subboff model
Resistance measurement and cfd test on darpa subboff modelResistance measurement and cfd test on darpa subboff model
Resistance measurement and cfd test on darpa subboff model
INDIAN INSTITUTE OF TECHNOLOGY KHARAGPUR
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Structural Response of Reinforced Self-Compacting Concrete Deep Beam Using Fi...
Journal of Soft Computing in Civil Engineering
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Development of MLR, ANN and ANFIS Models for Estimation of PCUs at Different ...
Journal of Soft Computing in Civil Engineering
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Process Parameter Optimization for Minimizing Springback in Cold Drawing Proc...
Journal of Soft Computing in Civil Engineering
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
New Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdfNew Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdf
mohamedezzat18803
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 
How to use nRF24L01 module with Arduino
How to use nRF24L01 module with ArduinoHow to use nRF24L01 module with Arduino
How to use nRF24L01 module with Arduino
CircuitDigest
 
IntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdfIntroSlides-April-BuildWithAI-VertexAI.pdf
IntroSlides-April-BuildWithAI-VertexAI.pdf
Luiz Carneiro
 
Compiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptxCompiler Design_Lexical Analysis phase.pptx
Compiler Design_Lexical Analysis phase.pptx
RushaliDeshmukh2
 
Data Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptxData Structures_Searching and Sorting.pptx
Data Structures_Searching and Sorting.pptx
RushaliDeshmukh2
 
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptxExplainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
Explainable-Artificial-Intelligence-XAI-A-Deep-Dive (1).pptx
MahaveerVPandit
 
Value Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous SecurityValue Stream Mapping Worskshops for Intelligent Continuous Security
Value Stream Mapping Worskshops for Intelligent Continuous Security
Marc Hornbeek
 
Mathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdfMathematical foundation machine learning.pdf
Mathematical foundation machine learning.pdf
TalhaShahid49
 
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
211421893-M-Tech-CIVIL-Structural-Engineering-pdf.pdf
inmishra17121973
 
Introduction to FLUID MECHANICS & KINEMATICS
Introduction to FLUID MECHANICS &  KINEMATICSIntroduction to FLUID MECHANICS &  KINEMATICS
Introduction to FLUID MECHANICS & KINEMATICS
narayanaswamygdas
 
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design ThinkingDT REPORT by Tech titan GROUP to introduce the subject design Thinking
DT REPORT by Tech titan GROUP to introduce the subject design Thinking
DhruvChotaliya2
 
fluke dealers in bangalore..............
fluke dealers in bangalore..............fluke dealers in bangalore..............
fluke dealers in bangalore..............
Haresh Vaswani
 
ELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdfELectronics Boards & Product Testing_Shiju.pdf
ELectronics Boards & Product Testing_Shiju.pdf
Shiju Jacob
 
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITYADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ADVXAI IN MALWARE ANALYSIS FRAMEWORK: BALANCING EXPLAINABILITY WITH SECURITY
ijscai
 
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E..."Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
"Boiler Feed Pump (BFP): Working, Applications, Advantages, and Limitations E...
Infopitaara
 
New Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdfNew Microsoft PowerPoint Presentation.pdf
New Microsoft PowerPoint Presentation.pdf
mohamedezzat18803
 
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdfMAQUINARIA MINAS CEMA 6th Edition (1).pdf
MAQUINARIA MINAS CEMA 6th Edition (1).pdf
ssuser562df4
 

Class warshal2

  • 2. Key Points OF Discussion 1 • FB vs Google+ (graph types) • Transitive Closure 2 • Explanation of Warshall Algorithm • Complexity Analysis 3 • Applications of Warshall Algorithm
  • 4. Transitive Closure 1 • What is Transitivity ? • Express it in a graph : 2 • What is Transitive Closure ? • Express as a Matrix : • How can we find Transitive Closure of A Graph ?
  • 5. Finding Transitive Closure • Involves searching for the shortest path starting at every vertex. • If you start at ith vertex, after traversal you get columns containing 1 in the ith row. • Clearly it has a disadvantage (?) DFS Implementation • It involves finding the shortest path and improving the estimate on the path every single time, till its optimal. • However, this fails in case of negative cycles. Basic Point of The Warshall Algorithm
  • 6. Warshall Algorithm : Visitation Example
  • 7. Warshall Algorithm : Weighted Example
  • 9. Complexity Analysis : In this Bottom up Dynamic approach, D0 -> 0 D1 -> n2 problems , every problem is a value in a cell. n2xn where n2 denotes subproblems and n is no of matrices So,total number of problems that need to be solved are n3 Therefore Time complexity is O(n3) Space Complexity : D1->D0 D2->D1 D3->D2 At any point of time you need two matrices so O(n2)
  • 10. Applications of Warshall Algorithm 1. Shortest Path in Directed Graphs 2. Optimal Routing 3. Check if a graph is Bipartite 4. Pathfinder Networks 5. Inversion of Real Networks (Gauss Jordan Method)
  • 11. Key Questions 1 • What is the difference between D&C and DP ? • What is Dynamic Programming ? • Why is it called “Dynamic” ? 2 • What is Space Time Trade off ? • How is it implemented by DP ? • What are the applications of DP ? • What is a non optimizable problem ? 3 • What is transitive Closure ? • Warshall Algorithm discussion
  • 12. Fibonacci Series : An illustration fib(5) fib(4) fib(3) fib(3) fib(2) fib(2) fib(1) fib(2) fib(1) fib(1) fib(0) fib(1) fib(0) fib(1) fib(0) 6 5 21 3 4
  • 13. Divide and Conquer vs D.P  Clearly If We use Divide and Conquer, We face OVER LAP.  Mostly values are calculated again and again, so even though access of function is O(1) , the total time complexity is exponential or O(2n).  INSTEAD if we used DP. We would store each value in a table and access when required.  DP Time complexity becomes O(n)
  • 14. Why is it called “Dynamic Programming” ?
  • 15. Dynamic Programming : Basic Idea  Avoid calculating the same thing twice by keeping a table of known results, which we fill up as subinstances are solved.  Dynamic programming is a bottom-up / top down technique  Bottom up dynamic programming evaluates by computing all function values in order, starting at lowest and using previously computed values.  Can MERGE SORT Be solved using DP ?