Python中的二叉树查找算法模块使用指南

特别说明

树每每要比python内置的dict类慢一些,可是它中的全部数据都是按照某个关键词进行排序的,故在某些状况下是必须使用的。python

python中的二叉树模块内容:git

  • BinaryTree:非平衡二叉树
  • AVLTree:平衡的AVL树
  • RBTree:平衡的红黑树

使用例子:

from bintrees import RBTree

btree = RBTree()
btree.insert('111',"first")
btree.insert('333', "second")
btree.insert('2222', "thirdly")
print btree
# result :  RBTree({'111': 'first', '2222': 'thirdly', '333': 'second'})

注意:

其余API看源码或官方文档: https://github.com/mozman/bintreesgithub

相关文章
相关标签/搜索