Remove unnecessary code (#4141)

This commit is contained in:
Saurabh Rahate
2023-04-03 20:05:59 +05:30
committed by GitHub
parent 805f09850c
commit ad72c28d91
64 changed files with 125 additions and 322 deletions

View File

@ -17,21 +17,13 @@ public class CircularQueue {
}
public boolean isEmpty() {
if (beginningOfQueue == -1) {
return true;
} else {
return false;
}
return beginningOfQueue == -1;
}
public boolean isFull() {
if (topOfQueue + 1 == beginningOfQueue) {
return true;
} else if (topOfQueue == size - 1 && beginningOfQueue == 0) {
return true;
} else {
return false;
}
} else return topOfQueue == size - 1 && beginningOfQueue == 0;
}
public void enQueue(int value) {

View File

@ -91,13 +91,12 @@ public class Deques<T> {
if (tail == null) {
// If the deque is empty, add the node as the head and tail
head = newNode;
tail = newNode;
} else {
// If the deque is not empty, insert the node as the new tail
newNode.prev = tail;
tail.next = newNode;
tail = newNode;
}
tail = newNode;
size++;
}

View File

@ -177,6 +177,6 @@ public class Queues {
System.out.println(myQueue.peekFront()); // Will print 2
System.out.println(myQueue.peekRear()); // Will print 7
System.out.println(myQueue.toString()); // Will print [2, 5, 3, 7]
System.out.println(myQueue); // Will print [2, 5, 3, 7]
}
}