AVL Tree¶
Source code: src/pydsadoc/_tree/avl.py
- class AVL(*args, **kwargs)¶
The AVL tree impelemented with linked list.
- post_order()¶
Implementation of post-order traversal with stacks.
Implementation Details¶
The AVL tree is somewhat more difficult than other data structures, so there
are some implementation details to be shown.
These methods mainly form the basics of the AVL.insert() and
AVL.remove() operations described above.
Methods for Maintaining Balance
- AVL._adjust(node: AVLNode, /) AVLNode¶
Adjust the tree after removing or inserting.
- AVL._rotation_left(node: AVLNode, /) AVLNode¶
The left rotaion of the tree.
- AVL._rotation_right(node: AVLNode, /) AVLNode¶
The right rotaiton of the tree.
Other Methods
- AVL._get_min(node: AVLNode, /) AVLNode¶
Return the minimum element in the tree.
Time complexity is \(O(\log n)\).