We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 46bbfaa commit b73757eCopy full SHA for b73757e
DataStructures/Queues/PriorityQueues.java
@@ -37,6 +37,10 @@ public PriorityQueue(int size){
37
public void insert(int value){
38
if(nItems == 0){
39
queueArray[0] = value;
40
+ nItems++;
41
+ }
42
+ else if(isFull()){ //does not insert value when the queue is full
43
+ System.out.println("Queue is full");
44
}
45
else{
46
int j = nItems;
@@ -45,8 +49,8 @@ public void insert(int value){
49
j--;
50
47
51
queueArray[j] = value; //Once the correct position is found the value is inserted
52
48
53
- nItems++;
54
55
56
/**
@@ -120,4 +124,4 @@ public static void main(String args[]){
120
124
121
125
//As you can see, a Priority Queue can be used as a sorting algotithm
122
126
123
-}
127
+}
0 commit comments