COMPUTER SCIENCE AND ENGINEERING
DATA STRUCTURES
Question
[CLICK ON ANY CHOICE TO KNOW THE RIGHT ANSWER]
|
|
running time of enqueue() is improved
|
|
reuse empty spaces
|
|
you can traverse all the elements more efficiently
|
|
none of the above
|
Detailed explanation-1: -Explanation: As the insertion in the queue is from the rear end and in the case of Linear Queue of fixed size insertion is not possible when rear reaches the end of the queue. But in the case of Circular Queue, the rear end moves from the last position to the front position circularly.
Detailed explanation-2: -Advantages of the Circular Queue Over Linear Queue Flexible insertion and deletion: In a circular Queue, elements can be added till the Queue isn’t full. But in the linear Queue, you can not add more elements once the rear end points to the last index.
Detailed explanation-3: -Easier for insertion-deletion: In the circular queue, if the queue is not fully occupied, then the elements can be inserted easily on the vacant locations. But in the case of a linear queue, insertion is not possible once the rear pointer reaches the last index even if there are empty locations present in the queue.
Detailed explanation-4: -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.
Detailed explanation-5: -In linear queue, insertion is done from the rear end, and deletion is done from the front end. In circular queue, the insertion and deletion can take place from any end. The memory space occupied by the linear queue is more than the circular queue. It requires less memory as compared to linear queue.