Tag: heap
-
Dijkstra Algorithm in JavaScript, heap based fast implementation
Let’s pick up from where we left off and revisit the problem Dijkstra algorithm aims to solve. Input: directed graph G = (V, E) in adjacency-list representation, a source vertex s ∈ V, a length le ≥ 0 for each e ∈ E. Output: the true shortest-path distance to every vertex v from the source…
-
Priority queue min heap implementation in JavaScript
Here’s what I’ve learned about the heap data structure. The invariant of the min/max heap is this: when represented in a binary tree, the parent node’s value is always smaller/bigger than or equal to its children. The root is always the smallest/biggest value of the heap when represented as a binary tree. The two most…