Is the queue last in first out or first in first out?
王先生
王先生 2019-10-09 16:01:51
0
3
13972

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?

王先生
王先生

reply all(2)
十亿亿

You may have mistaken the stack and the queue. The stack is last in, first out. The queue is first in, first out.

  • reply Please read my description carefully and try it yourself several times. Don't jump to conclusions so quickly. At first I thought the teacher had made a mistake. After careful consideration later, I found that it was correct. It just depends on how you understand it. The queue mentioned on the Internet, the so-called "first in, first out", refers to the elements at the front of the array that come out of the queue first. There is no
    王先生 author 2019-10-10 08:50:21
王先生

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template