data-structures-queues Flashcards
1
Q
What does the acronym FIFO mean?
A
First-in-first-out: The first thing “enqueue”d onto the queue is the first thing that be “dequeue”d out.
2
Q
What methods are available on a Queue data structure?
A
- enqueue(value) - adds a value to the back of the queue
- dequeue() - removes the “front” value from the queue and returns it
- peek() - returns the “front” value of the queue without removing it
3
Q
What must you do to access the value at an arbitrary point in a queue (not just the “front”)?
A
Keep “dequeue”ing the queue and store each “dequeue”d value in a variable until you reach the arbitrary point. Then you can “enqueue” the “dequeue”d values back onto the queue.