what is the basic difference between stack and queue?

后端 未结 11 835
死守一世寂寞
死守一世寂寞 2020-12-07 08:09

What is the basic difference between stack and queue??

Please help me i am unable to find the difference.

How do you differentiate a stack a

11条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-07 08:29

    Imagine a stack of paper. The last piece put into the stack is on the top, so it is the first one to come out. This is LIFO. Adding a piece of paper is called "pushing", and removing a piece of paper is called "popping".

    Imagine a queue at the store. The first person in line is the first person to get out of line. This is FIFO. A person getting into line is "enqueued", and a person getting out of line is "dequeued".

提交回复
热议问题