No, there is no balanced binary tree in stdlib. However, from your comments, it seems that you may have other options:
- You say you want to use BST instead of a list to search for
O(log n) . If search is all you need and your data is already sorted, the bisect module provides a binary search algorithm for lists. - Mike DeSimone recommended dialing and dicts, and you explained why lists are too algorithmically slow. Sets and dicts are implemented as hash tables that have O (1) lookups. Solving most of the problems in Python is actually "using a dict."
If none of the solutions is right for you, you will have to upgrade to a third-party module or implement your own.
Mike Graham Feb 19 '10 at 17:26 2010-02-19 17:26
source share