Concepts20

โš™๏ธAlgorithmAdvanced

Johnson's Algorithm

Johnson's Algorithm computes all-pairs shortest paths on sparse graphs by first removing negative edges via reweighting, then running Dijkstra from every vertex.

#johnson's algorithm#all pairs shortest paths#apsp+12
โš™๏ธAlgorithmIntermediate

Bellman-Ford Algorithm

Bellmanโ€“Ford finds single-source shortest paths even when some edge weights are negative.

#bellman-ford#single-source shortest paths#negative weights+12
โš™๏ธAlgorithmIntermediate

Dijkstra - Variations and Applications

Dijkstraโ€™s algorithm can be adapted to track the second shortest path by keeping the best and second-best distances per vertex.

#dijkstra#second shortest path#k shortest paths+12
โš™๏ธAlgorithmIntermediate

Topological Sort - DP on DAG

Topological sort orders vertices of a directed acyclic graph (DAG) so every edge goes from earlier to later, which is perfect for dynamic programming (DP).

#topological sort#dag dp#longest path dag+12
โš™๏ธAlgorithmIntermediate

Topological Sort

Topological sort orders the nodes of a directed acyclic graph (DAG) so every edge points from left to right in the order.

#topological sort#kahn algorithm#dfs topological order+12
โš™๏ธAlgorithmIntermediate

Multi-Source BFS

Multi-source BFS explores an unweighted graph starting from several sources at once to compute the minimum distance to any source for every vertex.

#multi-source bfs#graph algorithms#shortest path+11
๐Ÿ—‚๏ธData StructureAdvanced

Centroid Decomposition - Distance Queries

Centroid decomposition splits a tree into levels by repeatedly removing a centroid so that each remaining component is at most half the size.

#centroid decomposition#tree distance queries#nearest red node+12
๐Ÿ—‚๏ธData StructureIntermediate

Queue and Deque

A queue is a First-In-First-Out (FIFO) line where you add at the back and remove from the front in O(1) time.

#queue#deque#fifo+12