Grokking 75: Top Coding Interview Questions
Ask Author
Back to course home

0% completed

Heap Operations
Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Let's cover basic operations on heap in this lesson.

1. Find Maximum/Minimum in a Heap

The simplest operation in a heap is retrieving the maximum or minimum element.

  • In a Max Heap, the largest element is always at the root (index 0 in the array representation).
  • In a Min Heap, the smallest element is always at the root (index 0 in the array representation).

Since heaps maintain a complete binary tree structure, accessing the maximum (for max heap) or minimum (for min heap) is a constant-time operation with O(1) complexity

.....

.....

.....

Like the course? Get enrolled and start learning!

Table of Contents

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible

Contents are not accessible