We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent bd0cfc2 commit 616a3f0Copy full SHA for 616a3f0
src/main/java/com/thealgorithms/datastructures/queues/ReverseQueueRecursion.java
@@ -8,19 +8,20 @@
8
public final class ReverseQueueRecursion {
9
10
private ReverseQueueRecursion() {
11
- // private constructor to prevent instantiation
+ // Private constructor to prevent instantiation
12
}
13
14
/**
15
* Reverses the given queue recursively.
16
*
17
* @param queue the queue to reverse
18
- * @param <T> type of elements in the queue
+ * @param <T> the type of elements in the queue
19
*/
20
public static <T> void reverseQueue(final Queue<T> queue) {
21
if (queue == null || queue.isEmpty()) {
22
return;
23
24
+
25
final T front = queue.poll();
26
reverseQueue(queue);
27
queue.add(front);
0 commit comments