71.4k views
1 vote
Queue is the LIFO structure.

o True

o False

User Friggle
by
5.5k points

1 Answer

0 votes

Answer:

The answer is False.

Step-by-step explanation:

By definition LIFO structure is defined by: Last In, First Out.

By definition FIFO structure is defined by: First In, First Out.

A queue has the basics operations push() and pop() where:

  • push(element) stores the element at the end of the queue.
  • element = pop() retrieves the element at the beginning of the queue.

For example:

If you insert the elements doing the push(e) and q.pop(e) operation:

Queue q;

Element e;

q.push(2); // q ={2};

q.push(5); // q ={2 , 5};

q.push(6); // q = {2, 5, 6};

q.pop(e); // q ={5, 6}; e = 2;

q.push(12); q ={5, 6, 12};

q.pop(e); // q ={6, 12}; e = 5;

Note: A stack is a LIFO structure.

User Cumhur Ata
by
4.6k points