The five items A, B, C, D and E are pushed in a stack one after the other starting from A. The stack is popped 4 times and each element is inserted in a queue then 2 element are deleted form the queue and pushed back on the stack. Now 1 item is popped from the stack the popped item is _________.
Stack is an ordered list of similar data type. Stack is a LIFO (Last in First out) structure or FILO (First in Last out). Push () function is used to insert new elements into the Stack and pop () function is used to remove an element from the stack.
Queue is a data structure. Unlike stacks, a queue is open at both its ends. One end is always used to insert data (enqueue) and the other is used to remove data (dequeue). Queue follows First-In-First-Out and the data item stored first will be accessed first.
We pushed five elements A to E.
E
D
C
B
A