COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
Avoid wastage of memory
|
|
Access the Queue using priority
|
|
Follows the FIFO principle
|
|
None of the above
|
Detailed explanation-1: -Which of the following determines the need for the Circular Queue? Explanation: The answer is, i.e., Avoid wastage of memory.
Detailed explanation-2: -Easier for insertion-deletion: In the circular queue, elements can be inserted easily if there are vacant locations until it is not fully occupied, whereas in the case of a linear queue insertion is not possible once the rear reaches the last index even if there are empty locations present in the queue.
Detailed explanation-3: -A circular queue has been implemented using a singly linked list where each node consists of a value and a single pointer pointing to the next node. We maintain exactly two external pointers FRONT and REAR pointing to the front node and the near node of the queue, respectively.
Detailed explanation-4: -Which one of the following is the overflow condition if a circular queue is implemented using array having size MAX? Explanation : front=(rear+1) mod max. The overflow condition for the linear queue is rear =MAX-1 as there is no space left in the Queue if rear = MAX-1.
Detailed explanation-5: -If the queue is empty, then you must write an underflow error and exit. Additionally, if there is only one element in the queue, you should set both the front and rear pointer to NULL. Otherwise, you will simply increment the front pointer using the technique of circular incrementation.