- Related Questions & Answers
- Symmetric Min-Max Heaps
- Removing the Min Element from Interval Heaps
- Merge two binary Max Heaps using C++.
- max() and min() in Python
- Perform min/max with MongoDB aggregation
- Use of min() and max() in Python
- Sorting max to min value in MySQL
- Convert min Heap to max Heap in C++
- Find Min-Max in heterogeneous list in Python
- How to use min and max attributes in HTML?
- Min and max values of an array in MongoDB?
- Pairing Heaps
- Soft Heaps
- How to find Min/Max numbers in a java array?
- List Methods in Python - in, not in, len(), min(), max()

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

A min-max heap is defined as a complete binary tree containing alternating min (or even) and max (or odd) levels. Even levels are denoted as for example 0, 2, 4, etc, and odd levels are denoted as 1, 3, 5, etc.

We consider in the next points that the root element is at the first level, i.e., 0.

Example of Min-max heap

- Each node in a min-max heap is associated with a data member (usually called key) whose value is implemented to calculate the order of the node in the min-max heap.
- The root element is the minimum element in the min-max heap.
- One of the two elements in the second level, which is a max (or odd) level, is the maximum element in the min-max heap
- Let y be any node in a min-max heap.
- If y is on a min (or even) level, then y.key is the smallest key among all keys in the subtree with root y.
- If y is on a max (or odd) level, then y.key is the highest key among all keys in the subtree with root y.
- A node on a min (max) level is denoted as a min (max) node.

A max-min heap is defined as opposite to min-max heap; in such a heap, the highest value is stored at the root, and the minimum value is stored at one of the root's children.

Advertisements