Elwin's Blog

an activist who likes to think

Month: August 2021

front cover

Implement a MinHeap in Javascript

Posted on

It's useful when looking for a subset with certain quality in a stream, like Kth largest Element or Kth smallest Element.

The keypoint is understand how to get the parent index when bubble up, and left child index and right child index when trickle down, below is the implementation with comments:

Continue reading