public static void enQueue(int data){
if(isFull()){
throw new QueueOverflowException("Queue Overflow");
}else{
rear = (rear+1)%capacity;
array[rear] = data;
if(front == -1) front = rear;
}
}
}
If there is [1, 2, 3, 4, 5] in the array and 1 is the front,
If rear = (rear +1)% capacity is used, it becomes 6%5 = 1, and the rear is reset to 1 I thought about it, but I wonder if queue works like this!
queue
I was going to give you an answer.
I don't quite understand what you're sayingㅠ<
Please explain it a little bit
© 2024 OneMinuteCode. All rights reserved.