Is the queue last-in-first-out or first-in-first-out? The teacher said last in first out, but the actual result seems to be first in first out?
In addition, what is the difference between last in first out and first in last out?
十亿亿2019-10-10 08:38:18
You may have mistaken the stack and the queue. The stack is last in, first out. The queue is first in, first out.
王先生2019-10-09 18:02:14
Regarding the stack and queue modes, I personally think that the following explanation is reasonable:
Stack operation (first in, last out mode: refers to the newly pushed data on the stack. When it is popped out of the stack, it is in the order in which it was originally pushed into the stack. In order, the data is pushed into the stack first and then popped out. In fact, it is popped out from the last data in the order after being pushed into the stack) ##%2