Skip to content

bavetta/binary-tree

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

42 Commits
 
 
 
 
 
 

Repository files navigation

Self-Balancing Binary Tree

Python binary tree module that is self-balancing.

Note: There are probably better libraries that do what you want. Python "bisect" library performs binary search on lists. Additionaly, the "blist" package is awesome and includes "sortedlist" and "sorteddict" among others.

What Problem This Solves

  • Small space, Ave: O(n), Max: O(n)
  • Fast search, Ave: O(log n), Max: O(log n)
  • Fast insert, Ave: O(log n), Max: O(log n)
  • Fast delete, Ave: O(log n), Max: O(log n)
  • Objects with duplicate values may be added

How This Solves It

Uses AVL trees.

Usage

New tree

tree = BinaryTree()

Insert Entity into the tree

tree.insert(5, "optional unique ID")

About

Self-Balancing Binary Search Tree in Python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%