A queue is a data structure where items are added at the rear and removed from the front. This follows the FIFO principle, meaning the first item added is the first to be removed. We track two pointers: front points to the first item, rear points to the last. When we enqueue, we add a new node at rear and move rear pointer. When we dequeue, we remove the node at front and move front pointer. If the queue has one item, front and rear point to the same node. The example code enqueues 10 and 20, dequeues one item (removing 10), enqueues 30, then dequeues again (removing 20). The queue ends with one item 30. This shows how the queue maintains order and updates pointers step by step.