This PR contains several minimalistic (by their functionalities and implementation) data structures like MinHeap, MaxHeap, and DisjointSet that don't have external dependencies and that are easy to copy-paste and use during the coding interview if allowed by the interviewer.
What's the problem?
MaxHeapAdhoc
andMinHeapAdhoc
constructor can get an array for filling the heap initially.And then the constructors execute this:
But It did occur this error:
The problem is that if passing
this.add
method literally,this
used byadd
method isundefined
.This issue is confusing for the developers. And your intend is that
MaxHeapAdhoc
andMinHeapAdhoc
is used by developers easilyhttps://github.com/trekhleb/javascript-algorithms/pull/1117
How to fix