Is there a module for an AVL tree or a red–black tree or some other type of a balanced binary tree in the standard library of Python?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No, there is not a balanced binary tree in the stdlib. However, from your comments, it sounds like you may have some other options:
O(log n)searches. If searching is all you need and your data are already sorted, thebisectmodule provides a binary search algorithm for lists.If neither solution works well for you, you’ll have to go to a third party module or implement your own.