A queue is a data structure that works by only allowing you to insert elements at the rear of the list and then only allowing you to remove the elements from the front of the list. A queue is based on the first-in, first-out (FIFO) principle. A real-world example would be the line in a grocery store. The first people to get in line are the first ones to leave.