Skip to content

Commit 99e6f97

Browse files
committed
chore: format code
1 parent 8306158 commit 99e6f97

File tree

1 file changed

+31
-17
lines changed

1 file changed

+31
-17
lines changed

src/main/java/com/thealgorithms/datastructures/trees/SplayTree.java

Lines changed: 31 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,23 @@
55

66
/**
77
* Implementation of a Splay Tree data structure.
8-
*
9-
* A splay tree is a self-adjusting binary search tree with the additional property
8+
*
9+
* A splay tree is a self-adjusting binary search tree with the additional
10+
* property
1011
* that recently accessed elements are quick to access again. It performs basic
11-
* operations such as insertion, deletion, and searching in O(log n) amortized time,
12+
* operations such as insertion, deletion, and searching in O(log n) amortized
13+
* time,
1214
* where n is the number of elements in the tree.
13-
*
14-
* The key feature of splay trees is the splay operation, which moves a node closer
15+
*
16+
* The key feature of splay trees is the splay operation, which moves a node
17+
* closer
1518
* to the root of the tree when it is accessed. This operation helps to maintain
16-
* good balance and improves the overall performance of the tree. After performing
19+
* good balance and improves the overall performance of the tree. After
20+
* performing
1721
* a splay operation, the accessed node becomes the new root of the tree.
18-
*
19-
* Splay trees have applications in various areas, including caching, network routing,
22+
*
23+
* Splay trees have applications in various areas, including caching, network
24+
* routing,
2025
* and dynamic optimality analysis.
2126
*/
2227
public class SplayTree {
@@ -102,8 +107,10 @@ public List<Integer> traverse(TreeTraversal traversal) {
102107
* Zig operation.
103108
*
104109
* <p>
105-
* The zig operation is used to perform a single rotation on a node to move it closer to
106-
* the root of the tree. It is typically applied when the node is a left child of its parent
110+
* The zig operation is used to perform a single rotation on a node to move it
111+
* closer to
112+
* the root of the tree. It is typically applied when the node is a left child
113+
* of its parent
107114
* and needs to be rotated to the right.
108115
* </p>
109116
*
@@ -121,8 +128,10 @@ private Node rotateRight(Node x) {
121128
* Zag operation.
122129
*
123130
* <p>
124-
* The zag operation is used to perform a single rotation on a node to move it closer to
125-
* the root of the tree. It is typically applied when the node is a right child of its parent
131+
* The zag operation is used to perform a single rotation on a node to move it
132+
* closer to
133+
* the root of the tree. It is typically applied when the node is a right child
134+
* of its parent
126135
* and needs to be rotated to the left.
127136
* </p>
128137
*
@@ -140,23 +149,28 @@ private Node rotateLeft(Node x) {
140149
* Splay operation.
141150
*
142151
* <p>
143-
* The splay operation is the core operation of a splay tree. It moves a specified node
144-
* closer to the root of the tree by performing a series of rotations. The goal of the splay
145-
* operation is to improve the access time for frequently accessed nodes by bringing them
152+
* The splay operation is the core operation of a splay tree. It moves a
153+
* specified node
154+
* closer to the root of the tree by performing a series of rotations. The goal
155+
* of the splay
156+
* operation is to improve the access time for frequently accessed nodes by
157+
* bringing them
146158
* closer to the root.
147159
* </p>
148160
*
149161
* <p>
150162
* The splay operation consists of three main cases:
151163
* <ul>
152164
* <li>Zig-Zig case: Perform two consecutive rotations.</li>
153-
* <li>Zig-Zag case: Perform two consecutive rotations in opposite directions.</li>
165+
* <li>Zig-Zag case: Perform two consecutive rotations in opposite
166+
* directions.</li>
154167
* <li>Zag-Zag case: Perform two consecutive rotations.</li>
155168
* </ul>
156169
* </p>
157170
*
158171
* <p>
159-
* After performing the splay operation, the accessed node becomes the new root of the tree.
172+
* After performing the splay operation, the accessed node becomes the new root
173+
* of the tree.
160174
* </p>
161175
*
162176
* @param root The root of the subtree to splay.

0 commit comments

Comments
 (0)