Back to Trending
RepositorySolidityAUAustralia
bokkypoobah

bokkypoobah/BokkyPooBahsRedBlackTreeLibrary

BokkyPooBah's Red-Black Binary Search Tree Library

158stars
22forks
3issues
0views

🌲 BokkyPooBahs Red-Black Tree Library — Cây tìm kiếm tự cân bằng O(log n) cho Solidity

Thư viện Solidty dùng thuật toán Red-Black Tree lặp (không đệ quy), tối ưu gas, hỗ trợ insert/delete/search O(log n).

Đây là thư viện Solidity giúp duy trì một chỉ mục uint đã sắp xếp cho dữ liệu trên chuỗi. Sử dụng cây tìm kiếm nhị phân Red-Black tự cân bằng, mọi thao tác thêm, xóa, tìm kiếm đều chạy trong O(log n). Phù hợp cho trường hợp dùng như sổ lệnh on-chain trong DEX, cung cấp thuật toán matching đơn cửng minh.

✨ Điểm nổi bật

  • Thuật toán lặp (iterative): tránh đệ quy, tiết kiệm gas.
  • O(log n): insert, delete, search đều hiệu quả.
  • Gas tối ưu: insert trống 68,459 gas; insert 10k keys ~127,210 gas; delete ~44k–81k gas.
  • Chỉ mục sắp xếp: dùng để truy cập dữ liệu mapping theo thứ tự.
  • Key 0 cấm: tránh xung đột giá trị mặc định.
  • Bug bounty: đang được kiểm thử, chưa dùng production nếu chưa audit.

💡 Vì sao đáng chú ý

Khác với cây tìm kiếm nhị phân thường (có thể mất cân bằng thành danh sách liên kết khi thêm tuần tự), Red-Black Tree duy trì độ cân bằng bằng quy tắc tô màu nút. Phù hợp cho DEX cần sổ lệnh công bằng, minh bạch trên blockchain.


#Solidity #RedBlackTree #SmartContract #BinarySearchTree #GasOptimization #Ethereum #TiniX

Similar Projects

Discover other similar projects and AI models.

RepositorySolidity
OpenZeppelin/openzeppelin-contracts

OpenZeppelin Contracts is a library for secure smart contract development.

27.3k
Oct 21, 2026
RepositoryRust
unionlabs/union

The trust-minimized, zero-knowledge bridging protocol, designed for censorship resistance, extremely high security, and usage in decentralized finance.

73.7k
Jul 25, 2026
RepositoryC++
argotorg/solidity

Solidity, the Smart Contract Programming Language

25.8k
Oct 22, 2026
Repository
ethereumbook/ethereumbook

Mastering Ethereum: 2nd Edition, by Andreas M. Antonopoulos, Gavin Wood, Carlo Parisi, Alessandro Mazza, Niccolò Pozzolini

21.5k
Oct 12, 2026
RepositorySolidity
SunWeb3Sec/DeFiHackLabs

Reproduce DeFi hacked incidents using Foundry.

6.8k
Oct 20, 2026
RepositoryJavaScript
OffcierCia/DeFi-Developer-Road-Map

DeFi Developer roadmap is a curated Developer handbook which includes a list of the best tools for DApps development, resources and references!

10.9k
Oct 20, 2026
RepositoryRust
foundry-rs/foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.

10.7k
Oct 26, 2026
RepositoryTypeScript
NomicFoundation/hardhat

Hardhat is a development environment to compile, deploy, test, and debug your Ethereum software.

8.5k
Oct 24, 2026
RepositoryGo
smartcontractkit/chainlink

node of the decentralized oracle network, bridging on and off-chain computation

8.3k
Oct 26, 2026