5/26/2023 0 Comments Program antrian cWhen REAR = MAX – 1, where MAX is the size of the queue, we have an overflow condition. An overflow will occur when we try to insert an element into a queue that is already full. However, before inserting an element in a queue, we must check for overflow conditions. Deletions are done from only this end of the queue.Īfter deleting first element(12) from queue, FRONT=1. If we want to delete an element from the queue, then the value of FRONT will be incremented. Every time a new element has to be added, we repeat the same procedure. In the above figure initially FRONT =0 and REAR =4, after adding a new element with value 36, REAR would be incremented by 1 and the value would be stored at the position pointed by REAR. Queues can be easily represented using linear arrays as show in the above figure. This makes queue as FIFO(First in First Out) data structure, which means that element inserted first will be removed first. Queues can be implemented by using either arrays or linked lists. The elements in a queue are added at one end called the REAR and removed from the other end called the FRONT. A queue is a FIFO (First-In, First-Out) data structure in which the element that is inserted first is the first one to be taken out.
0 Comments
Leave a Reply. |