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 ?

More Related Content

What's hot

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
 
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
 

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]
 
[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]
 
Search
SearchSearch
Search
 
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]
 
[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]
 
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]
 
[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]
 
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]
 
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]
 
Breadth first search signed
Breadth first search signedBreadth first search signed
Breadth first search signed
 
NP completeness
NP completenessNP completeness
NP completeness
 
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]
 
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...
 
artificial intelligence
artificial intelligence artificial intelligence
artificial intelligence
 
Complexity theory
Complexity theory Complexity theory
Complexity theory
 
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...
 
Uninformed Search technique
Uninformed Search techniqueUninformed Search technique
Uninformed Search technique
 
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]
 
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
 
[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 / ...
 

Viewers also liked

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
 
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
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
 
(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
 
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
 

Viewers also liked (20)

Greedy Algorihm
Greedy AlgorihmGreedy Algorihm
Greedy Algorihm
 
Freeing India of “Divide & Rule”
Freeing India of “Divide & Rule” Freeing India of “Divide & Rule”
Freeing India of “Divide & Rule”
 
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
 
Chap08alg
Chap08algChap08alg
Chap08alg
 
Dynamic programming in Algorithm Analysis
Dynamic programming in Algorithm AnalysisDynamic programming in Algorithm Analysis
Dynamic programming in Algorithm Analysis
 
Load balancing
Load balancingLoad balancing
Load balancing
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Greedyalgorithm
Greedyalgorithm Greedyalgorithm
Greedyalgorithm
 
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
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
(floyd's algm)
(floyd's algm)(floyd's algm)
(floyd's algm)
 
Dynamic programming
Dynamic programmingDynamic programming
Dynamic programming
 
Solving The Shortest Path Tour Problem
Solving The Shortest Path Tour ProblemSolving The Shortest Path Tour Problem
Solving The Shortest Path Tour Problem
 
21 backtracking
21 backtracking21 backtracking
21 backtracking
 
Load Balancing with Apache
Load Balancing with ApacheLoad Balancing with Apache
Load Balancing with Apache
 
DP
DPDP
DP
 
5.5 back track
5.5 back track5.5 back track
5.5 back track
 
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
 
Covering (Rules-based) Algorithm
Covering (Rules-based) AlgorithmCovering (Rules-based) Algorithm
Covering (Rules-based) Algorithm
 

Similar to Class warshal2

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
 
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 algorithm gSpan algorithm
gSpan algorithm
Sadik Mussah
 
gSpan algorithm
gSpan algorithmgSpan algorithm
gSpan algorithm
Sadik Mussah
 
Topological Sort Algorithm.pptx
Topological Sort Algorithm.pptxTopological Sort Algorithm.pptx
Topological Sort Algorithm.pptx
MuhammadShafi89
 
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
 
GR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf
 
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
AdaCore
 
Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)
Igalia
 
Terascale Learning
Terascale LearningTerascale Learning
Terascale Learningpauldix
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
JAX London
 

Similar to Class warshal2 (20)

Search algorithms for discrete optimization
Search algorithms for discrete optimizationSearch algorithms for discrete optimization
Search algorithms for discrete optimization
 
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
 
Slides
SlidesSlides
Slides
 
Genetic programming
Genetic programmingGenetic programming
Genetic programming
 
Lecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdfLecture 16 - Dijkstra's Algorithm.pdf
Lecture 16 - Dijkstra's Algorithm.pdf
 
Deep learning
Deep learningDeep learning
Deep learning
 
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
 
Online learning, Vowpal Wabbit and Hadoop
Online learning, Vowpal Wabbit and HadoopOnline learning, Vowpal Wabbit and Hadoop
Online learning, Vowpal Wabbit and Hadoop
 
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
 
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)
 
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
 
gSpan algorithm
 gSpan algorithm gSpan algorithm
gSpan algorithm
 
gSpan algorithm
gSpan algorithmgSpan algorithm
gSpan algorithm
 
Topological Sort Algorithm.pptx
Topological Sort Algorithm.pptxTopological Sort Algorithm.pptx
Topological Sort Algorithm.pptx
 
Better DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-EclipseBetter DSL Support for Groovy-Eclipse
Better DSL Support for Groovy-Eclipse
 
GR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL SupportGR8Conf 2011: STS DSL Support
GR8Conf 2011: STS DSL Support
 
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
GNAT Pro User Day: Ada 2012, Ravenscar and SPARK running on an Atmel ARM M4 (...
 
Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)Mediump support in Mesa (XDC 2019)
Mediump support in Mesa (XDC 2019)
 
Terascale Learning
Terascale LearningTerascale Learning
Terascale Learning
 
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
Bluffers guide to elitist jargon - Martijn Verburg, Richard Warburton, James ...
 

More from 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
 
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
 

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
 
Carnegie ppt
Carnegie pptCarnegie ppt
Carnegie ppt
 
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
 
Boolean algebra
Boolean algebraBoolean algebra
Boolean algebra
 
Binary Codes and Number System
Binary Codes and Number SystemBinary Codes and Number System
Binary Codes and Number System
 
Lattices AND Hasse Diagrams
Lattices AND Hasse DiagramsLattices AND Hasse Diagrams
Lattices AND Hasse Diagrams
 

Recently uploaded

Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
manasideore6
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
Kamal Acharya
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
MIGUELANGEL966976
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
Massimo Talia
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Sreedhar Chowdam
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
symbo111
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
PauloRodrigues104553
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
Kamal Acharya
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
awadeshbabu
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
benykoy2024
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
aqil azizi
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
NidhalKahouli2
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
Mukeshwaran Balu
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
drwaing
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
SyedAbiiAzazi1
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
Divyam548318
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 

Recently uploaded (20)

Fundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptxFundamentals of Electric Drives and its applications.pptx
Fundamentals of Electric Drives and its applications.pptx
 
Water billing management system project report.pdf
Water billing management system project report.pdfWater billing management system project report.pdf
Water billing management system project report.pdf
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdfBPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
BPV-GUI-01-Guide-for-ASME-Review-Teams-(General)-10-10-2023.pdf
 
Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024Nuclear Power Economics and Structuring 2024
Nuclear Power Economics and Structuring 2024
 
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&BDesign and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
Design and Analysis of Algorithms-DP,Backtracking,Graphs,B&B
 
Building Electrical System Design & Installation
Building Electrical System Design & InstallationBuilding Electrical System Design & Installation
Building Electrical System Design & Installation
 
Series of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.pptSeries of visio cisco devices Cisco_Icons.ppt
Series of visio cisco devices Cisco_Icons.ppt
 
Online aptitude test management system project report.pdf
Online aptitude test management system project report.pdfOnline aptitude test management system project report.pdf
Online aptitude test management system project report.pdf
 
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
[JPP-1] - (JEE 3.0) - Kinematics 1D - 14th May..pdf
 
01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx01-GPON Fundamental fttx ftth basic .pptx
01-GPON Fundamental fttx ftth basic .pptx
 
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdfTutorial for 16S rRNA Gene Analysis with QIIME2.pdf
Tutorial for 16S rRNA Gene Analysis with QIIME2.pdf
 
basic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdfbasic-wireline-operations-course-mahmoud-f-radwan.pdf
basic-wireline-operations-course-mahmoud-f-radwan.pdf
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
ACRP 4-09 Risk Assessment Method to Support Modification of Airfield Separat...
 
digital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdfdigital fundamental by Thomas L.floydl.pdf
digital fundamental by Thomas L.floydl.pdf
 
14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application14 Template Contractual Notice - EOT Application
14 Template Contractual Notice - EOT Application
 
bank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdfbank management system in java and mysql report1.pdf
bank management system in java and mysql report1.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 

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 ?