Python icon indicating copy to clipboard operation
Python copied to clipboard

feat: add Splay Tree implementation in data_structures/binary_tree

Open krrish175-byte opened this issue 2 months ago • 0 comments

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.

krrish175-byte avatar Oct 29 '25 09:10 krrish175-byte