Skip to main content
Z

Binary Heap Visualizer — Insert & Extract-Max

Interactive binary max-heap — insert and extract-max with animated sift-up / sift-down, step controls and pseudocode. Runs in your browser.

Free No signup Client-side Privacy friendly Updated

/

Pseudocode

Run an operation to see its steps.

How to use

  1. 1 Type a number and press Insert — watch it "sift up" to its correct level.
  2. 2 Press Extract Max to remove the root and watch the heap "sift down".
  3. 3 Use Random to insert a random value, or Clear to empty the heap.
  4. 4 Step through any operation and follow the highlighted pseudocode.

Why use this tool

  • See a binary max-heap as a tree, with the largest value always at the root.
  • Watch sift-up after insert and sift-down after extract restore the heap property.
  • Understand why insert and extract are both O(log n) — the height of the tree.
  • Runs entirely in your browser. No signup, no uploads.

Frequently asked questions

What is a binary heap?

A binary heap is a complete binary tree stored in an array where every parent satisfies the heap property. In a max-heap each parent is ≥ its children (so the maximum is at the root); in a min-heap each parent is ≤ its children.

What is the time complexity of heap operations?

Insert and extract-max are O(log n) — they bubble a value up or down at most the height of the tree. Reading the max is O(1).

How is a heap stored in an array?

The tree is implicit: the node at index i has children at 2i+1 and 2i+2 and its parent at ⌊(i−1)/2⌋. No pointers are needed.

What are heaps used for?

Priority queues, heap sort, Dijkstra’s and Prim’s algorithms, and any task that repeatedly needs the largest (or smallest) remaining element.

What is Binary Heap Visualizer?

A Binary Heap Visualizer animates a binary max-heap — a complete binary tree (stored in an array) where each parent is greater than or equal to its children. It shows sift-up after an insert and sift-down after extracting the maximum, keeping the largest value at the root.

Features

Insert / extract / peek

Animate sift-up on insert and sift-down on extract of the root.

Complexity

insert / extract: O(log n). peek: O(1). build-heap: O(n). Space: O(n).

100% private

Runs entirely in your browser — nothing is uploaded.

Example

Input

insert 5, 3, 8, 1, 4 (min-heap)

Output

heap array = [1, 3, 8, 5, 4] (root = min = 1)

Common use cases

  1. 1

    Priority queues

    See the heap that backs an efficient priority queue.

  2. 2

    Heap sort & Dijkstra

    Understand the structure used by heap sort and Dijkstra.

  3. 3

    Learn sift-up/sift-down

    Watch how the heap property is restored after each operation.

Summary

Zerethon's binary heap visualizer animates a min- or max-heap in your browser, showing insert (sift-up) and extract (sift-down) as the complete-tree heap property is restored. Insert and extract run in O(log n), peek in O(1), and building a heap from an array in O(n); space is O(n).

Category
Algorithm
Pricing
Free
Privacy
Browser-based
Signup
Not required

References

Privacy

Your data never leaves your browser unless explicitly stated. Binary Heap Visualizer runs entirely client-side — no server upload, no logging, no tracking of your input.

New to this? Read the step-by-step explanation with Big-O analysis: Learn Data Structures →

Related tools

Build, share, and grow on Zerethon Social

Free signup. Earn points, collect achievements, and connect with creators worldwide.

Sign up free