Skip to content

Resource · Guide or article

Heap (data-structure)

Defines min and max heaps through the parent-child ordering rule and compares operation costs across many heap variants. Most useful as a quick lookup before rounds that use priority queues.

Reviewed

Open the original: Heap (data-structure) (opens the original site in a new tab)

Practice this topicOpens the practice interviewer in Technical / coding mode; choose a question there.

Add to a roadmap

Keep this resource with a roadmap you follow. It appears as your own extra resource; the roadmap's steps don't change and it doesn't count toward your tracked steps.

Source content: English

Read this in other languages: 简体中文, Русский, 日本語, Français, Português, Türkçe, 한국어, Українська In computer science, a heap is a specialized tree-based data structure that satisfies the heap property described below. In a min heap, if P is a parent node of C, then the key (the value) of P is less than or equal to the key of C.

PrepKit overview

PrepKit editors wrote and reviewed this overview from the source repository. It is not text from the resource itself.

Suited to
The source does not state a level
Format
Reference

What it covers

  • Min heap and max heap property, with diagrams that include the array representation
  • Table of find-max, delete-max, insert, increase-key and meld costs for binary, leftist, binomial, Fibonacci, pairing and other heaps
  • Binary heap listed at Θ(1) find-max, Θ(log n) delete-max, O(log n) insert and Θ(n) meld
  • Points to dependency-free MinHeapAdhoc and MaxHeapAdhoc files meant for pasting in interviews where allowed

How to use it

PrepKit study advice, not a claim made by the source.

Implement a binary min heap on an array, with sift-up and sift-down, and use it to return the k smallest numbers from a list. Check the result against a sorted copy.

Scope and limitations

No pseudocode for sift-up or sift-down, and nothing on building a heap from an array. Most rows in the comparison table go beyond typical interview needs.

Access and format

README on GitHub in trekhleb/javascript-algorithms (MIT); it links the folder's JavaScript heap files and eight translations. English, free.

Reviewed by PrepKit on Oct 2, 2026. Listing source commit: 85293e3e2b88

Evidence behind this overview
  • src/data-structures/heap/README.md

Pages that include this

Get the PrepKit newsletter

Optional. You don't need it to use PrepKit.

How we handle your email