What is a queue?
- Karla G
- 28 mar 2015
- 1 Min. de lectura
A queue:
Plan B of queue:
(information gotten from http://interactivepython.org/)
What Is a Queue?
A queue is an ordered collection of items where the addition of new items happens at one end, called the “rear,” and the removal of existing items occurs at the other end, commonly called the “front.” As an element enters the queue it starts at the rear and makes its way toward the front, waiting until that time when it is the next element to be removed.
The Queue Abstract Data Type
The queue abstract data type is defined by the following structure and operations. A queue is structured, as described above, as an ordered collection of items which are added at one end, called the “rear,” and removed from the other end, called the “front.” Queues maintain a FIFO ordering property. The queue operations are given below.
Queue() creates a new queue that is empty. It needs no parameters and returns an empty queue.
enqueue(item) adds a new item to the rear of the queue. It needs the item and returns nothing.
dequeue() removes the front item from the queue. It needs no parameters and returns the item. The queue is modified.
isEmpty() tests to see whether the queue is empty. It needs no parameters and returns a boolean value.
size() returns the number of items in the queue. It needs no parameters and returns an integer.
Queues Examples:
A music queue (the reproduction list)
The waiting list i youtube
References:
Brad Miller, David Ranum.. (2014). Queues. 27 Marzo del 2015, de http://interactivepython.org/ Sitio web: http://interactivepython.org/LpOMZ/courselib/static/pythonds/BasicDS/TheStackAbstractDataType.html
Comments