If you're familiar with heaps, you've probably used them in priority queues, heapsort, or maybe even to tackle those tricky DSA problems. But have you ever heard of a Beap? Beap Beap stands for bi-parental heap — a clever structure introduced by Ian Munro and Hendra Suwanda in 1984. It's designed to make both insertion and search operations efficient, giving us O(√n) time complexity for both. Beap stands for bi-parental heap — a clever structure introduced by Ian Munro and Hendra Suwanda in 1984. It's designed to make both insertion and search operations efficient, giving us O(√n) time complexity for both. bi-parental heap In this story, we'll explore: 🧱 What makes a beap different from a regular heap 🧠 How core operations like insert, extract, search, and min/max work in a beap 🎥 And of course, animated visualizations to help bring these concepts to life 🧱 What makes a beap different from a regular heap 🧠 How core operations like insert, extract, search, and min/max work in a beap 🎥 And of course, animated visualizations to help bring these concepts to life animated visualizations 🆚 Heap vs Beap: What’s the Difference? Heaps are the go-to for priority queues and sorting, but they follow a strict binary tree model: each node has at most one parent and two children, and the heap property ensures the parent is smaller (in a min-heap) or larger (in a max-heap) than its children. Beaps flip that idea by arranging elements in a triangular matrix, where nodes — except on the boundaries — can have two parents and two children. This structure enables an elegant, grid-like representation that makes search operations far more efficient. triangular matrix Feature Binary Heap Beap Structure Binary Tree Triangular Matrix Parents per Node 1 Up to 2 Children per Node Up to 2 Up to 2 Search Complexity O(n) O(√n) Insert Complexity O(log n) O(√n) Use Cases Heapsort, PQs Fast search + insert Feature Binary Heap Beap Structure Binary Tree Triangular Matrix Parents per Node 1 Up to 2 Children per Node Up to 2 Up to 2 Search Complexity O(n) O(√n) Insert Complexity O(log n) O(√n) Use Cases Heapsort, PQs Fast search + insert Feature Binary Heap Beap Feature Feature Binary Heap Binary Heap Beap Beap Structure Binary Tree Triangular Matrix Structure Structure Binary Tree Binary Tree Triangular Matrix Triangular Matrix Parents per Node 1 Up to 2 Parents per Node Parents per Node 1 1 Up to 2 Up to 2 Children per Node Up to 2 Up to 2 Children per Node Children per Node Up to 2 Up to 2 Up to 2 Up to 2 Search Complexity O(n) O(√n) Search Complexity Search Complexity O(n) O(n) O(√n) O(√n) Insert Complexity O(log n) O(√n) Insert Complexity Insert Complexity O(log n) O(log n) O(√n) O(√n) Use Cases Heapsort, PQs Fast search + insert Use Cases Use Cases Heapsort, PQs Heapsort, PQs Fast search + insert Fast search + insert This triangular matrix layout allows search to start from the bottom-left and proceed smartly based on comparisons. 📌 Here's a diagram to help you visualize a beap: 📖 Learn more on Wikipedia Learn more on Wikipedia 🔧 Core Operations (With GIFs) Let’s walk through how each operation works — and yes, we’ve animated them so you don’t have to imagine the pointer gymnastics. 🔼 Insert We insert an element into the next available triangle position, then bubble up by comparing it with its two parents (if they exist). bubble up 🔽 Extract Min In a min-beap, the smallest element is always at the top. Removing it means replacing it with the last element and then bubbling down. bubbling down 🔍 Search Searching is where beaps shine. Start at the bottom-left, and depending on comparisons, move either up or right. Time complexity: O(√n). O(√n) ⬇️ Min & ⬆️ Max Min is always at the root. Max is in the last level (bottom-right corner). Min is always at the root. Min Max is in the last level (bottom-right corner). Max 🎓 Wrapping Up Beaps may not be part of the standard algorithm toolkit, but they offer a compelling blend of structure and performance. Their unique design and search mechanics make them worth exploring, whether you're deep into data structure theory or just curious about alternatives to the usual heap. If you're interested in checking out the full code and visual demos, you can find them on GitHub. GitHub