Pre-Requisites: What are binary heaps?
See here.
I personally found the implementation given in the above GeeksForGeeks link very long.
The aim of this post is simply to provide a short and efficient implementation of min and max heap in C++.
This helps me to revise just before the placement interviews too. :P
Advantage:
1. Short and efficient code.
2. Works as both max-heap as well as min-heap.
Here is the link of code at ideone.
This is my blog dedicated to competitive programming. I write about interesting data structures, algorithms and beautiful problems that have awesome analysis and thus offer great learning.
Subscribe to:
Post Comments (Atom)
Art of Time Management | Achieving Multiple Things in Life
rachit jain blog, Rachit Jain, rachit jain iit roorkee, rachit jain iitr, rachit iitr,rachit codechef, rachit hackerrank, rachit jain micr...
-
Wavelet Trees, Wavelet trees editorial, wavelet trees tutorial, wavelet tree rachit jain, Rachit Jain, rachit jain iit roorkee, rachit iit...
-
Rachit Jain, rachit iit roorkee, rachit iitr, rachit codechef, rachit hackerrank, rachit jain microsoft Tags: small-to-large trick, d...
-
rachit jain blog, Rachit Jain, rachit jain iit roorkee, rachit jain iitr, rachit iitr,rachit codechef, rachit hackerrank, rachit jain micr...
No comments:
Post a Comment