Determining the size of the queue
The size operation informs the caller of the current size of the queue. Similar to the array implementation, we utilize the currentSize variable that we maintain. Without storing that, the only method to determine the size of a linked list is to traverse it, which is very costly. For this reason, we keep the currentSize variable in the queue class that tracks the current size of the queue.
Loading Image
Size of the queue is stored in a member variable of the queue class
Algorithm
Liking the course? Check our discounted plans to continue learning.