{
  "schema_version": "1.0",
  "codex": "thecodex.expert/coding",
  "type": "data-structure",
  "slug": "data-structures/heaps",
  "name": "Heaps",
  "confidence": "high",
  "last_verified": "2026-06-01",
  "url": "https://thecodex.expert/coding/data-structures/heaps/",
  "canonical_definition": "A heap is a complete binary tree stored as an array satisfying the heap property \u2014 each node >= its children (max-heap) or <= (min-heap) \u2014 providing O(1) find-max and O(log n) insert and extract.",
  "complexity": {
    "find_max": "O(1)",
    "insert": "O(log n)",
    "extract_max": "O(log n)",
    "build_heap": "O(n)",
    "space": "O(n)"
  },
  "concept_relationship": {
    "requires_first": [
      "data-structures/arrays",
      "concepts/recursion"
    ],
    "enables": [
      "algorithms/sorting/heapsort"
    ]
  },
  "sources": [
    {
      "num": 1,
      "citation": "CLRS 4th ed. Ch.6",
      "tier": 1
    },
    {
      "num": 2,
      "citation": "Williams 1964 CACM 7(6)",
      "tier": 1
    },
    {
      "num": 3,
      "citation": "Fredman & Tarjan 1987 JACM 34(3)",
      "tier": 1
    },
    {
      "num": 4,
      "citation": "Python heapq docs",
      "tier": 1
    }
  ]
}