Tag: javascript

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…

Graph data structure in JavaScript
Here’s what I’ve learned about the graph data structure. Let’s start. We will represent the graph as an adjacency list, which is an object (or a hash table) that maps each vertex to an array of its adjacent vertices. This is a simple and efficient way to store the graph structure in JavaScript. To add…