0
0
DSA Typescriptprogramming~5 mins

Floyd Warshall All Pairs Shortest Path in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What problem does the Floyd Warshall algorithm solve?
It finds the shortest paths between all pairs of nodes in a weighted graph, including graphs with negative edge weights but no negative cycles.
Click to reveal answer
intermediate
What is the main idea behind the Floyd Warshall algorithm?
It uses dynamic programming to update shortest paths by considering each node as an intermediate point, improving paths step-by-step until all shortest paths are found.
Click to reveal answer
intermediate
In Floyd Warshall, what does the matrix entry dist[i][j] represent during the algorithm?
It represents the shortest known distance from node i to node j considering only intermediate nodes from the set {1, 2, ..., k} at step k.
Click to reveal answer
beginner
What is the time complexity of the Floyd Warshall algorithm?
The time complexity is O(n³), where n is the number of nodes in the graph, because it uses three nested loops over all nodes.
Click to reveal answer
advanced
Can Floyd Warshall detect negative weight cycles? If yes, how?
Yes, by checking if any dist[i][i] becomes negative after the algorithm finishes, indicating a negative cycle reachable from node i.
Click to reveal answer
What does Floyd Warshall algorithm compute?
AShortest paths between all pairs of nodes
BShortest path from a single source to all nodes
CMinimum spanning tree
DTopological sort
Which of these is true about Floyd Warshall algorithm?
AIt can handle negative edges but no negative cycles
BIt works only on graphs without negative edges
CIt finds shortest paths using BFS
DIt uses a priority queue
What is the main data structure used in Floyd Warshall?
AAdjacency list
BQueue
CStack
DDistance matrix
What does a negative value in dist[i][i] after Floyd Warshall indicate?
ANo path exists
BGraph is disconnected
CNegative weight cycle reachable from node i
DAlgorithm failed
What is the time complexity of Floyd Warshall algorithm?
AO(n log n)
BO(n³)
CO(n²)
DO(m + n)
Explain how Floyd Warshall algorithm updates the shortest path matrix step-by-step.
Think about dynamic programming and intermediate nodes.
You got /4 concepts.
    Describe how Floyd Warshall algorithm can detect negative weight cycles in a graph.
    Focus on the meaning of dist[i][i] after algorithm finishes.
    You got /3 concepts.