enqueue(x) / push(x)
O(1) Time. Inserts element `x` at the Rear (tail) of the queue. If using a fixed-size array, you must check for Overflow before inserting.
Loading...
Loading Curriculum...
Loading Subject...
Loading Topic...
Loading Lesson...
Loading Lab...
A high-level overview of the standard methods available on a Queue data structure across most programming languages.
O(1) Time. Inserts element `x` at the Rear (tail) of the queue. If using a fixed-size array, you must check for Overflow before inserting.
O(1) Time. Removes and returns the element at the Front (head) of the queue. You must check for Underflow (IsEmpty) before popping.
O(1) Time. Returns the value of the element at the Front of the queue without removing it. Crucial for checking the next item in line.
O(1) Time. Returns a boolean indicating whether the queue contains any elements. In array implementations, this is true if `front == -1` or `front > rear`.