Tech
Thoughts on implementing a custom Priority Queue in TS
LC 1046
My two cents:
Each push and pop requires a rearrangement of the existing elements, it's almost like the priority queue is a living organism which evolves / devolves it self to maintain the order of the elements.
Swap, BubbleUp, & BubbleDown are the methods doing the main lifting. Here, swap is the simple swap operation
const temp: T = this.heap[i];
this.heap[i] = this.heap[j];
this.heap[j] = temp
The this.compare dependency injection is the soul of th...
Read the full discussion on Dev.to
This article was aggregated from Dev.to. Click to join the conversation.
View on Dev.to