Write down the function to insert an element into a queue, in which the queue isimplemented as an array.

Q – Queue

X – element to added to the queue Q IsFull(Q)
– Checks and true if Queue Q is full Q->Size – Number of elements in the queue Q Q->Rear – Points to last element of the queue Q Q->Array – array used to store queue elements void
enqueue (int X, Queue Q) {
if(IsFull(Q))

Error (“Full queue”);
else {

Q->Size++;

Q->Rear = Q->Rear+1;

Q->Array[ Q->Rear ]=X;

}

}


Discover more from Soa Technology | Aditya Website Development Designing Company

Subscribe to get the latest posts sent to your email.



Leave a Reply

Discover more from Soa Technology | Aditya Website Development Designing Company

Subscribe now to keep reading and get access to the full archive.

Continue reading