MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
We need to implement a queue using a circular array. If DATA is a circular array of n elements, and rear is an index into that array, what will be the index for the element after rear?
A
rear + (1 % n)
B
(rear + 1) % n
C
rear % (1 + n)
D
rear % 1 + n
Explanation: 

Detailed explanation-1: -A circular queue will be full when Front =-1 and Rear = max – 1.

Detailed explanation-2: -The conditions to detect queue full and queue empty area)full: (REAR+1) mod n == FRONTempty: REAR == FRONT$b)full: (REAR+1) mod n == FRONTempty: (FRONT+1) mod n == REARc)full: REAR == FRONTempty: (REAR+1) mod n == FRONTd)full: (FRONT+1) mod n == REARempty: REAR == FRONTCorrect answer is option ‘A’.

Detailed explanation-3: -So, what all we can say is Front = Rear ≠ NULL if only one element is there in circular queue.

There is 1 question to complete.