Suppose the letter A is placed in an empty queue, followed by the letters B and C, in that order. Then suppose that a letter is removed from the queue and the letters D and E are inserted. List the letters that would be in the queue in the order they would appear from head to tail. If a letter is now removed from the queue, which letter will it be?
Queue:
Queue works on FIFO rule ( First In First Out ) . The element which is entered first will be deleted first. Queue has mainly two operations.
Enqueue : Inserting element from top
Dequeue : Deleting element from bottom / Start point
1) So first A is entered and then B, C are inserted at top of it. and if we have to remove a letter we have to remove it from bottom. i.e A in below example.
2) Later D and E are inserted
Now the queue is in order B, C, D, E
3) After removing a element
Now order of queue is C, D, E
Get Answers For Free
Most questions answered within 1 hours.