Max Heap: Skeleton Code #

Let’s start with some function declarations for the heap class.

The __percolateUp() function is meant to restore the heap property going up from a node to the root.

The __maxHeapify() function restores the heap property starting from a given node down to the leaves.

The two underscores before the __percolateUp() and __maxHeapify() functions imply that these functions should be treated as private functions.

Level up your interview prep. Join Educative to access 80+ hands-on prep courses.