Queue Flashcards
Is Queue Random or Sequential Access?
Sequential
A Queue is a data structure in which we add elements and remove elements according to LIFO or FIFO?
FIFO. First In, First Out.
What is a real life analogy of a Queue.
An actual queue of people. The first one to join the queue is the first one to leave the queue.
The back of a Queue is also called the…
Rear or Tail
The front of a Queue is also called the…
Front or Head
We add elements to the …. of the Queue.
Back or Tail
We remove elements from the …. of the Queue.
Front or Head
What method do we use to add an element to a Queue?
Enqueue
What method do we use to remove an element from a Queue?
Dequeue [not to be confused with double-ended queue]
What are the four fairly standard Queue methods?
enqueue, dequeue, peek, contains
What does the peek() method do?
It returns the element at the front/head of the queue without removing it from the Queue.
What does the contains() method do?
Returns whether or not the Queue contains an element.
What is the BigO for ACCESSING an element in a Queue?
O(n). Worst-case the element you want will be at the tail of the queue.
What is the BigO for SEARCHING an element in a Queue?
O(n). Linear Search.
What is the BigO for INSERTING an element in a Queue?
O(1)