A Queue is a linear structure which follows a particular order in which the operations are performed. The order is First In First Out (FIFO). A good example of a queue is any queue of consumers for a resource where the consumer that came first is served first. The difference between stacks and queues is in removing. In a queue, we remove the item that was least recently added.


  • FIFO (First In First Out)
  • Think “Customers in a line”


  • CPU Scheduling
  • Disk Scheduling
  • IO Buffers
  • Pipes
  • File IO



Returns a Bool with true if the queue is empty or false if the queue has elements.


Returns an Int with the number of elements in the queue.

queue.enqueue(_ element: Element)

Adds the given element to the back of the queue.

queue.dequeue() -> SinglyLinkedListNode?

Removes the node from the front of the queue and returns the node.

queue.peek() -> SinglyLinkedListNode?

Returns the node from the front of the queue.

Queue with Linked List Implementation



Leave a Reply