Queue

From Wiki :-)
Revision as of 00:17, 23 October 2020 by Savoundg (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

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.