Commit 50c2b34
authored
Add Splay Tree implementation (#13760) [hacktoberfest]
This PR adds a Splay Tree (Self Adjusting BST) implementation in Python under the `data_structures/binary_tree/` directory.
## Details:
- Implements the Splay Tree data structure with all core operations: insertion, search, splay rotation, and inorder traversal.
- Includes class-based design (`Node`, `SplayTree`) and follows Python community style.
- Provides an example usage and test in the `__main__` block.
## Why Splay Tree?
A Splay Tree is a self-adjusting binary search tree that provides fast access to recently used elements by moving them closer to the root through 'splaying' operations. Frequently accessed nodes move towards the top, which is useful for caching and memory management systems.
## Issue Reference
This solves [Issue #13760](#13760).
## Hacktoberfest
Marking this contribution for Hacktoberfest 2025.
**For Maintainers:** Please add the `hacktoberfest-accepted` label to count this PR towards Hacktoberfest.
## Checklist
- [x] Follows contribution guidelines
- [x] Code is documented with docstrings and inline comments
- [x] Includes an example/test case
- [x] New file in correct directory
---
Feel free to use or modify the text above for your commit and pull request! If you want it in Hinglish or need a quick summary, let me know.1 parent 22f137d commit 50c2b34
1 file changed
+42
-24
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
15 | 18 | | |
16 | 19 | | |
17 | 20 | | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
21 | 24 | | |
| 25 | + | |
| 26 | + | |
22 | 27 | | |
23 | 28 | | |
24 | 29 | | |
| |||
34 | 39 | | |
35 | 40 | | |
36 | 41 | | |
| 42 | + | |
| 43 | + | |
37 | 44 | | |
38 | 45 | | |
39 | 46 | | |
| |||
48 | 55 | | |
49 | 56 | | |
50 | 57 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
55 | 65 | | |
56 | | - | |
| 66 | + | |
57 | 67 | | |
58 | | - | |
59 | | - | |
60 | | - | |
61 | | - | |
62 | | - | |
63 | | - | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
68 | | - | |
69 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
70 | 82 | | |
71 | 83 | | |
72 | 84 | | |
| |||
89 | 101 | | |
90 | 102 | | |
91 | 103 | | |
| 104 | + | |
92 | 105 | | |
| 106 | + | |
93 | 107 | | |
94 | 108 | | |
95 | 109 | | |
96 | 110 | | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | 111 | | |
101 | 112 | | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | 113 | | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
106 | 117 | | |
107 | 118 | | |
108 | 119 | | |
109 | 120 | | |
110 | 121 | | |
111 | | - | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
112 | 127 | | |
113 | 128 | | |
114 | 129 | | |
| |||
120 | 135 | | |
121 | 136 | | |
122 | 137 | | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
123 | 141 | | |
124 | 142 | | |
125 | 143 | | |
| |||
0 commit comments