
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
This library was created to simplify the concept of a heap by showing that it is simply an array that is treated as a complete binary tree with some additional properties such as maximum and minimum binary heap that help us solve some programming issues such as array sorting and priority queue this library is specially designed for beginners in data structures
You can install heep via pip:
pip install heep
from heep import minBinaryHeap
x = minBinaryHeap([5, 4, 6, 2, 8, 1, 3, 7, 9])
print(x)
[1, 2, 3, 4, 8, 6, 5, 7, 9]
from heep import minBinaryHeap
x = minBinaryHeap([5, 4, 6, 2, 8, 1, 3, 7, 9], detail=True)
print(x)
╒════════════════╤══════════════╤═══════════════╕
│ Current node │ Left child │ Right child │
╞════════════════╪══════════════╪═══════════════╡
│ 1 │ 2 │ 3 │
├────────────────┼──────────────┼───────────────┤
│ 2 │ 4 │ 8 │
├────────────────┼──────────────┼───────────────┤
│ 3 │ 6 │ 5 │
├────────────────┼──────────────┼───────────────┤
│ 4 │ 7 │ 9 │
├────────────────┼──────────────┼───────────────┤
│ 8 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 6 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 5 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 7 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 9 │ None │ None │
╘════════════════╧══════════════╧═══════════════╛
from heep import minBinaryHeap
x = minBinaryHeap([5, 4, 6, 2, 8, 1, 3, 7, 9], detail=True)
print(x)
x.add(0)
print(x)
╒════════════════╤══════════════╤═══════════════╕
│ Current node │ Left child │ Right child │
╞════════════════╪══════════════╪═══════════════╡
│ 1 │ 2 │ 3 │
├────────────────┼──────────────┼───────────────┤
│ 2 │ 4 │ 8 │
├────────────────┼──────────────┼───────────────┤
│ 3 │ 6 │ 5 │
├────────────────┼──────────────┼───────────────┤
│ 4 │ 7 │ 9 │
├────────────────┼──────────────┼───────────────┤
│ 8 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 6 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 5 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 7 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 9 │ None │ None │
╘════════════════╧══════════════╧═══════════════╛
╒════════════════╤══════════════╤═══════════════╕
│ Current node │ Left child │ Right child │
╞════════════════╪══════════════╪═══════════════╡
│ 0 │ 1 │ 3 │
├────────────────┼──────────────┼───────────────┤
│ 1 │ 4 │ 2 │
├────────────────┼──────────────┼───────────────┤
│ 3 │ 6 │ 5 │
├────────────────┼──────────────┼───────────────┤
│ 4 │ 7 │ 9 │
├────────────────┼──────────────┼───────────────┤
│ 2 │ 8 │ None │
├────────────────┼──────────────┼───────────────┤
│ 6 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 5 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 7 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 9 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 8 │ None │ None │
╘════════════════╧══════════════╧═══════════════╛
from heep import minBinaryHeap
x = minBinaryHeap([5, 4, 6, 2, 8, 1, 3, 7, 9], detail=True)
print(x.get_min())
1
from heep import minBinaryHeap
x = minBinaryHeap([5, 4, 6, 2, 8, 1, 3, 7, 9], detail=True)
print(x)
print(f"Extracted Value: {x.extract_min()}")
print(x)
╒════════════════╤══════════════╤═══════════════╕
│ Current node │ Left child │ Right child │
╞════════════════╪══════════════╪═══════════════╡
│ 1 │ 2 │ 3 │
├────────────────┼──────────────┼───────────────┤
│ 2 │ 4 │ 8 │
├────────────────┼──────────────┼───────────────┤
│ 3 │ 6 │ 5 │
├────────────────┼──────────────┼───────────────┤
│ 4 │ 7 │ 9 │
├────────────────┼──────────────┼───────────────┤
│ 8 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 6 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 5 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 7 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 9 │ None │ None │
╘════════════════╧══════════════╧═══════════════╛
Extracted Value: 1
╒════════════════╤══════════════╤═══════════════╕
│ Current node │ Left child │ Right child │
╞════════════════╪══════════════╪═══════════════╡
│ 2 │ 4 │ 3 │
├────────────────┼──────────────┼───────────────┤
│ 4 │ 7 │ 8 │
├────────────────┼──────────────┼───────────────┤
│ 3 │ 6 │ 5 │
├────────────────┼──────────────┼───────────────┤
│ 7 │ 9 │ None │
├────────────────┼──────────────┼───────────────┤
│ 8 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 6 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 5 │ None │ None │
├────────────────┼──────────────┼───────────────┤
│ 9 │ None │ None │
╘════════════════╧══════════════╧═══════════════╛
from heep import minBinaryHeap
x = minBinaryHeap([5, 4, 6, 2, 8, 1, 3, 7, 9], detail=True)
print(len(x))
9
The same methods in maxBinaryHeap with get_max and extract_max.
This project is licensed under the MIT LICENSE - see the LICENSE for more details.
FAQs
Sophisticate Heap
We found that heep demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.

Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.

Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.