In a queue data structure the following items are inserted in following order bob alice charlie eve zebra.then an item is removed from tje queue.that itrm will be
Answers
Answered by
0
Answer:
Following is C like pseudo code of a function that takes a Queue as an argument, and uses a stack S to do processing.
void fun(Queue *Q)
{
Stack S; // Say it creates an empty stack S
// Run while Q is not empty
while (!isEmpty(Q))
{
// deQueue an item from Q and push the dequeued item to S
push(&S, deQueue(Q));
}
// Run while Stack S is not empty
while (!isEmpty(&S))
{
// Pop an item from S and enqueue the poppped item to Q
enQueue(Q, pop(&S));
}
}
Similar questions
Math,
4 months ago
Hindi,
4 months ago
History,
4 months ago
Math,
8 months ago
Chemistry,
1 year ago
Business Studies,
1 year ago
Social Sciences,
1 year ago