![]() |
FIFO stands for First In, First Out, which is a common way of organizing and manipulating Data Structure. In FIFO, the first element that is added to the data structure is the same first element that is to be removed first. Queue is a FIFO-based Data Structure. Here, the insert operation is called Enque, and it is added always at the start, and the delete operation is called the Deque and it is the first element that is removed. Implementation of FIFO-based QueueIn this article, we will be using a dynamic array to implement our queue. Here, the index is pointing towards the head of the queue. As mentioned, that queue should support both enque and deque, so we need a starting index to show the start point. Program to Implement a FIFO-based Queue in JavaBelow is the implemented code in Java: Java
Output
5 3 Explanation of the Program:
Complexities of the Program mentioned above:
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 12 |