MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
In a circular queue, how do you increment the rear end of the queue?
A
rear++
B
(rear+1) % Number of Item
C
(rear % Number of Item)+1
D
rear-
Explanation: 

Detailed explanation-1: -When we insert the first element in a Queue, front and rear both are set to 0. When we insert a new element, the rear gets incremented, i.e., rear=rear+1.

Detailed explanation-2: -Explanation: The answer is c. If the queue is implemented using a linked list, then the new element will be inserted at the tail position of the linked list as Queue follows FIFO principle in which a new element will always be added at the end of the Queue.

Detailed explanation-3: -Rear-Used to get the end element of the Circular Queue. enQueue(value)-Used to insert a new value in the Circular Queue. This operation takes place from the end of the Queue. deQueue()-Used to delete a value from the Circular Queue. This operation takes place from the front of the Queue.

Detailed explanation-4: -It means that when REAR reaches MAX-1 position then Increment in REAR causes REAR to reach at first position that is 0. rear = ( rear + 1) % MAX; As we know that, Deletion causes the increment in FRONT.

There is 1 question to complete.