
We can also change size of the queue with AI when requirement increases/decreases. With the help of AI we can understand the current requirement of the system and according we can set the size of the queue. And AI can also help in implementing queue, How ?Īs we already seen benefits of fixed capacity queue, so defining the size of the queue is one of the major task in implementing queue. lets understand it.ĪI is one of the most emerging field of computer science and technology, today almost every company uses AI for building/getting suggestions/understanding/ products and customer requirements. So basically queue is implemented using arrays, so where is Artificial Intelligence in it.

In normal queue or we can say dynamic queue where its capacity is not pre defined or fixed, there are many challenges with it.

In the previous picture the size of the queue is 5 because it is holding 5 integers. It is a queue, and the size of the queue is fixed, it means that the queue cannot hold more than specified limit of number of data. Fixed Size/Capacity Queueīasically its name itself gives the answer. Now let's understand what fixed size queue is and why we need it. If the elements we inserted into the queue exceed the defined size then Queue Overflow message shows.So by this example, we understood what is queue and how does it work.

As for the enqueue method, it doesn't need the size of the Event elements, as the data array doesn't store the elements themselves, but references to the elements, and the references are of a fixed size, regardless of. It is always checked at the time of Enqueue of the element in the Queue. data.length will just return the size of the static array data, so in this case the size you passed to the Queue constructor. We will always check Overflow and Underflow conditions at the time of insertion/Enqueue or deletion/Dequeue of the element from the Queue.Ī Queue may be limited with the size (in Array) depending on the implementation so we need to check the Queue, not in any of the condition i.e Overflow and Underflow so we can perform the operations on it. Synchronization during data transfer: Asynchronous data transfers use a queue to keep track of the data.CPU Scheduling: Various CPU scheduling algorithms make use of this data structure to implement multiprocessing.Some other example is Sending request to the server. The student comes first for admission in the line gets the admission first and leaves the line first. Unlike Stack, In Queue we will insert elements from one end and delete the elements from another end.Ī good real-time example of Queue is a line of students who are in a line to take the admission in college. Example of Queue is anything, It always in a manner where element comes in first and leave/removed first. Now, In Queue we are talking about the examples.
