So far we've looked at implementation of tree data structure and some of it's variants such as trie. In this post, we'll dive into heaps. These are also referred to as priority queues. Introduction Heap is a variant of tree data structure, with two a...

Markdown supported · ⌘↵ to post
percolateDown function is exactly same as heappop. This won't create a heap of out an array. If the initial array is [3,5,4,10,2,1]. After percolateDown's execution array will be [3,2,1,10,5,4] which is still not a heap. Edit: for some one looking at it in future. In heapify function, instead of running from first node to last. It should run from last to first so (let i = last;i>=0;i--)
gr
Thanks for this amazing writeup!