Idea: Count how the work grows with the queue size $n$.
For enqueue, the operation touches only the rear end. With a tail pointer (linked list) or a rear index (array), you place the new node and move the pointer forward. That cost is the same for an empty queue or a queue holding a million items.
\[T(n) = c \quad \text{(a constant, independent of } n)\]
An operation whose cost does not scale with $n$ is constant time. The linear, log-linear, and logarithmic choices all imply the work grows with $n$, which does not happen here.
\[\boxed{O(1)}\]
Was this answer helpful?
0
Top Questions on Data Structures - Binary Search Tree