- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

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

# Initializing an Interval Heap

An interval heap is same as an embedded min-max heap in which each node contains two elements. It is defined as a complete binary tree in which

- The left element is smaller than or equal to the right element.
- Both the elements define a interval which is closed.
- Interval represented by any node other than the root is a sub-interval of the parent node.
- Elements on the left hand side represent a min heap.
- Elements on the right hand side represent a max heap.

Depending on the number of elements, two cases are permitted -

- Even number of elements: In this case, each node contains two elements say a and b, with a ≤ b. Every node is then represented by the interval [a, b].
- Odd number of elements: In this case, each node other than the last contains two elements represented by the interval [a, b] whereas the last node will contain a single element and is represented by the interval [a, b].

Interval heaps may be initialized implementing a strategy same as that used to initialize ordinary heaps--work our way from the heap bottom to the root ensuring that each sub tree is denoted as an interval heap. For each sub tree, first order the elements in the root; then again insert the left end point of this sub tree’s root implementing the reinsertion strategy used for the removeMin function, then again insert the right end point of this sub tree’s root implementing the strategy used for the removeMax function.

- Related Articles
- Complexity of Interval Heap Operations
- Initializing HashSet in Java
- Initializing HashSet in C#
- Initializing a List in Java
- Inserting an Element in Interval Heaps
- Convert min Heap to max Heap in C++
- C++ Program to Initializing a Dictionary
- Heap Sort
- Python Pandas - Check if an element belongs to an Interval
- Program to find one minimum possible interval to insert into an interval list in Python
- Python Program to Print Numbers in an Interval
- Python Pandas - Check if an interval is empty
- Program to check heap is forming max heap or not in Python
- Python Heap Queue Algorithm
- Heap Sort in C#

Advertisements