Skip to content

Commit 5431d3e

Browse files
committed
chore: reorganize code structure
1 parent a917047 commit 5431d3e

File tree

1 file changed

+13
-12
lines changed

1 file changed

+13
-12
lines changed

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

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,19 @@ public void delete(final int key) {
8686
root.right = temp.right;
8787
}
8888
}
89+
90+
/**
91+
* Perform a traversal of the SplayTree.
92+
*
93+
* @param traversal The type of traversal method.
94+
* @return A list containing the keys in the specified traversal order.
95+
*/
96+
public List<Integer> traverse(TreeTraversal traversal) {
97+
List<Integer> result = new LinkedList<>();
98+
traversal.traverse(root, result);
99+
return result;
100+
}
101+
89102
/**
90103
* Finds the node with the maximum key in a given subtree.
91104
*
@@ -104,18 +117,6 @@ private Node findMax(Node root) {
104117
return root;
105118
}
106119

107-
/**
108-
* Perform a traversal of the SplayTree.
109-
*
110-
* @param traversal The type of traversal method.
111-
* @return A list containing the keys in the specified traversal order.
112-
*/
113-
public List<Integer> traverse(TreeTraversal traversal) {
114-
List<Integer> result = new LinkedList<>();
115-
traversal.traverse(root, result);
116-
return result;
117-
}
118-
119120
/**
120121
* Zig operation.
121122
*

0 commit comments

Comments
 (0)