![]() ![]() Firstly check whether the queue is not empty.It will traverse the queue and print all the elements of the queue. Otherwise, we will return the FRONT index value.If the queue is empty then we display that the queue is empty we simply return from the function and not execute further inside the function.First of all we need to check that queue is not empty.If REAR=FRONT then we set -1 to both FRONT AND REAR.If front = - 1 or front > rear then no element is available to delete.But if REAR rear to check whether there is at least one element available for the deletion or not.If n-1=REAR then this means the queue is already full.Insert an element from the rear end into the queue.Įlement is inserted into the queue after checking the overflow condition n-1=REAR to check whether the queue is full or not. The REAR value represents the index up to which value is stored in the queue and the FRONT value represents the index of the first element to be dequeued Enqueue And initialize two variables FRONT and REAR with -1which means currently queue is empty. Implementation of queue using array starts with the creation of an array of size n. The addition of an element happens at an end known as REAR and deletion happens at the FRONT end. In queue insertion and deletion of elements takes place at two different ends. The queue is the linear data structure that works on the principle of FIFO( First In First Out). Write a program that implements the operations of queue using an array Implementation of Queue using Array Operations
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |