本文整理汇总了Python中bst.BinarySearchTree.traverse方法的典型用法代码示例。如果您正苦于以下问题:Python BinarySearchTree.traverse方法的具体用法?Python BinarySearchTree.traverse怎么用?Python BinarySearchTree.traverse使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bst.BinarySearchTree
的用法示例。
在下文中一共展示了BinarySearchTree.traverse方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: BinarySearchTree
# 需要导入模块: from bst import BinarySearchTree [as 别名]
# 或者: from bst.BinarySearchTree import traverse [as 别名]
"""
ASTR 598 HW 7
Brett Morris
"""
from __future__ import print_function # Python 2 compatibility
from bst import BinarySearchTree
# Generate some random integers:
import numpy as np
integers = np.random.randint(0, 1000, size=100).tolist()
bst = BinarySearchTree()
# Insert some random integers into the binary search tree:
for integer in integers:
bst.insert(integer)
# Traverse that tree in order (notice they're in order, wahoo!)
print("Traverse:")
bst.traverse()
# Find min, max:
print("Min: {0}, max: {1}".format(bst.min(), bst.max()))