Python
Python copied to clipboard
feat: add Splay Tree implementation in data_structures/binary_tree
Addressing #13760
Summary:
Added a Splay Tree implementation in Python under data_structures/binary_tree/splay_tree.py.
Features:
- [x] - Insert, search, delete operations with splay adjustments (zig, zig-zig, zig-zag)
- [x] - Inorder and preorder traversals
- [x] - Example usage in
__main__demonstrating basic behavior
]Rationale: The repository contains several balanced BSTs (AVL, Red-Black). Splay trees are a useful self-adjusting BST with amortized O(log n) complexity and are valuable for teaching and practical use-cases with access locality.
Tests:
Manual test via python data_structures/binary_tree/splay_tree.py demonstrates expected traversal and operations.
If the maintainers want doctests or additional unit tests, I can add them in a following commit.