what is the basic difference between stack and queue?

后端 未结 11 846
死守一世寂寞
死守一世寂寞 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:35

    Queue

    Queue is a ordered collection of items.

    Items are deleted at one end called ‘front’ end of the queue.

    Items are inserted at other end called ‘rear’ of the queue.

    The first item inserted is the first to be removed (FIFO).

    Stack

    Stack is a collection of items.

    It allows access to only one data item: the last item inserted.

    Items are inserted & deleted at one end called ‘Top of the stack’.

    It is a dynamic & constantly changing object.

    All the data items are put on top of the stack and taken off the top

    This structure of accessing is known as Last in First out structure (LIFO)

提交回复
热议问题