Queue: Difference between revisions

From Wiki :-)
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
Queue is a data structure that uses a FIFO (first-in first-out) upon which the following operations are supported:
Queue is a data structure that implements a FIFO (first-in first-out) ordering upon which the following operations are supported:
* queue(object): add object on the end of the queue O(1)
* queue(object): add object at the end of the queue O(1)
* pop(): remove the object which on the top of the stack O(1)
* dequeue(): remove the object which at the beginning of the stack O(1)
* peek(): return object which is on the top of the stack O(1)
* peek(): return object which is at the beginning of the stack O(1)
A queue can be used to implement BFS.
A queue can be used in BFS or to implement a cache.

Latest revision as of 00:17, 23 October 2020

Queue is a data structure that implements a FIFO (first-in first-out) ordering upon which the following operations are supported:

  • queue(object): add object at the end of the queue O(1)
  • dequeue(): remove the object which at the beginning of the stack O(1)
  • peek(): return object which is at the beginning of the stack O(1)

A queue can be used in BFS or to implement a cache.