0
0
DSA Typescriptprogramming~5 mins

Dijkstra's Algorithm Single Source Shortest Path in DSA Typescript - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main goal of Dijkstra's Algorithm?
To find the shortest path from a single starting point (source) to all other points (nodes) in a graph with non-negative edge weights.
Click to reveal answer
intermediate
In Dijkstra's Algorithm, what data structure is commonly used to select the next node with the smallest distance?
A priority queue (often implemented as a min-heap) is used to efficiently pick the node with the smallest current distance.
Click to reveal answer
intermediate
Why can't Dijkstra's Algorithm handle graphs with negative edge weights?
Because it assumes that once a node's shortest distance is found, it won't change. Negative edges can create shorter paths later, breaking this assumption.
Click to reveal answer
advanced
What is the time complexity of Dijkstra's Algorithm using a min-heap and adjacency list?
O((V + E) log V), where V is the number of vertices and E is the number of edges.
Click to reveal answer
intermediate
Explain the relaxation step in Dijkstra's Algorithm.
Relaxation means checking if the current known distance to a neighbor can be improved by going through the current node. If yes, update the neighbor's distance.
Click to reveal answer
What type of graph edges does Dijkstra's Algorithm require?
AOnly unweighted edges
BNon-negative edge weights
CNegative edge weights allowed
DEdges with zero weight only
Which data structure helps efficiently pick the next closest node in Dijkstra's Algorithm?
AStack
BQueue
CPriority Queue
DLinked List
What happens during the relaxation step?
AWe update the shortest distance to neighbors if a shorter path is found
BWe remove nodes from the graph
CWe add new edges to the graph
DWe reset all distances to infinity
What is the initial distance to the source node in Dijkstra's Algorithm?
ANegative one
BInfinity
COne
DZero
Which of these is NOT true about Dijkstra's Algorithm?
AIt works with negative edge weights
BIt updates distances through relaxation
CIt uses a priority queue for efficiency
DIt finds shortest paths from one source to all nodes
Describe the main steps of Dijkstra's Algorithm for finding shortest paths.
Think about how you keep track of shortest distances and update them.
You got /4 concepts.
    Explain why Dijkstra's Algorithm cannot handle negative edge weights and what could happen if it tries.
    Consider what happens if a shorter path appears after a node is finalized.
    You got /4 concepts.