MCQ IN COMPUTER SCIENCE & ENGINEERING

COMPUTER SCIENCE AND ENGINEERING

DATA STRUCTURES

Question [CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
What should be the value of rear (end) if the queue is full (elements are completely occupied )?
A
1
B
-1
C
MAX + 1
D
MAX-1
Explanation: 

Detailed explanation-1: -MAX-1 should be value of rear (end) if queue is full-Data Structure.

Detailed explanation-2: -Initially the queue is empty and value of front and rear is both-1. When an element is inserted the value of rear will be incremented by 1 and the element would be inserted at the array index specified by the rear variable.

Detailed explanation-3: -Check whether the queue is FULL ( rear == SIZE-1 ). If it is FULL, then display an error and terminate the function. If it is NOT FULL, then increment the rear value by one ( rear++ ) and set queue[rear] = value .

Detailed explanation-4: -queue::empty() is used to check whether the associated queue container is empty or not. This function returns either true or false, if the queue is empty (size is 0) then the function returns true, else if the queue is having some value then it will return false.

Detailed explanation-5: -If the queue is not empty, this function removes the element from the front of the queue, else it prints “UnderFlow”. This function returns the front element of the queue. This function returns the size of a queue or the number of elements in a queue.

There is 1 question to complete.