Queue
Learn Queue (Queue / Deque, Data Structures & Algorithms) with worked examples, diagrams and interview questions. Free on JavaSchoolLab.
What is a Queue? A queue is FIFO (First In, First Out) - the first element added is the first one removed, like a real-world line. Three core operations, all O(1) with the right backing structure: offer(x) / enqueue - add to the BACK poll() / dequeue - remove and return the FRONT peek() - look at the front without removing it In Java, Queue is an interface; LinkedList and ArrayDeque both implement it (ArrayDeque is generally faster).