Suppose there is no count variable stored for the linked implementation of a queue. Is it still possible to implement a constant time size operation? How about if there is no count variable stored for an array based implementation of a queue?
What will be an ideal response?
In the case of a linked implementation of a queue, it is not possible to implement a constant-time size
operation. The only way to determine the number of elements in the queue is to traverse the list, which would require a linear
number of steps. In the case of the array implementation, it is possible to implement a constant time size operation, by
determining the distance between the front and rear indexes. One special case to consider is whether or not the queue is empty
(since the front and rear indexes are the same when the queue is empty and when the queue is full). Therefore, it would be
necessary to store an isEmpty flag in the class.
You might also like to view...
The two tabs included in the Colors dialog box to make color choices are:
A) Color1 and Color2. B) Custom and Select. C) Cold and Warm. D) Standard and Custom.
The _______________ element was widely used but never part of the W3C standard until HTML5
a. object b. applet c. embed d. canvas