Last Updated: 16 November, 2024 4 Mins Read
A Queue is a linear data structure to store and manipulate the data elements. A queue follows the concept of "First in, First out" (FIFO), where the first element inserted into the queue is the first one to be deleted from the queue.
A queue is open at both ends which enables insert operations to be performed at one end called REAR or TAIL and delete operations to be performed at another end called FRONT or HEAD.
Enqueue: Add a new element to the end of the queue.
Dequeue: Remove an element from the front of the queue.
Peek or front: Retrieve the frontmost element in the queue without deleting it.
rear: Returns the element at the end in the queue without deleting it.
isFull: Checks if the queue is full.
Class: Node
Class: Queue
Output
Queue Front: 10 Queue Rear: 20 Queue Front: 30 Queue Rear: 50 Queue elements: 30 40 50
That's all, guys. I hope this article is helpful for you.
Happy Learning... 😀
feedback@javabytechie.com