You'll rarely write sift up and sift down yourself. Python, Java and C++ each ship a heap — and JavaScript doesn't, so this course writes one small class once and reuses it everywhere. Here's each language's heap, how to make it order things your way, and the traps that cost people marks.
The same small job in all four: put some numbers in a min-heap, then take them all out. They come out smallest first.
Free account
Sign up to read the rest of this lesson: 4 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++.
Still to come