How does a Queue<T> work internally? Follow:
Internally, Queue<T> uses a circular array to efficiently manage memory and operations.
- Head pointer marks the front (next item to be dequeued).
- Tail pointer marks where the next item will be enqueued.
- Automatically resizes when capacity is exceeded.
This implementation ensures constant time operations for enqueue and dequeue.