← Back to DSA Visualizer

Heap Visualization

A heap is a complete binary tree that satisfies the heap property. Max heap: parent ≥ children, Min heap: parent ≤ children. Perfect for priority queues and heap sort algorithm.

Heap Size

0

Heap Type

max

Root Element

None

Operation

None

Insert Element

Extract Root

Extract maximum element

Heap Type

Click to toggle between max and min heap

Actions

Root (Maximum)
Heap Node
Highlighted
Comparing
🔺

Empty Heap

Insert some elements or generate a random heap to get started!

Heap Operations

Heap Properties:

  • Complete Binary Tree: All levels filled except possibly last
  • Max Heap: Parent ≥ children
  • Min Heap: Parent ≤ children
  • Array Implementation: Parent at i, children at 2i+1, 2i+2

Time Complexities:

  • Insert: O(log n) - heapify up
  • Extract: O(log n) - heapify down
  • Peek Root: O(1) - constant time
  • Build Heap: O(n) - bottom-up construction