Queues Flashcards
a linear data structure that follows the First-In-First-Out (FIFO)principle.
Queues
(T or F)in queues first element added is the first one to be removed
True
(T or F)in queues It represents a collection of elements in which elements are added at one end (rear) and removed from the other end (front).
True
adds an element to the rear(end) of the queue. The newly added element becomes the last one in the queue.
Enqueue(insertion)
removes the element from the front of the queue. The next element in the queue becomes the new front.
Dequeue(deletion)
view the element at the front of the queue without removing it.
Peek
array-based
last element of the queue (where you add)
Rear
array-based
index of first element of the queue (where you delete)
Front
array-based
rear and front is -1
empty queue
array-based
rear is incremented by 1
new element is inserted at index rear
initially empty queue(front is -1) front is made 0
insertion
array-based
front is incremented by 1
element at index front is taken out
deletion
array-based
(T or F) If front is equal to rear, there is one element in the queue, except in initially empty queue
ex. front = 3, rear = 3
True
array-based
(T or F) Number of elements can be determined by
rear - front + 1, except empty queue
True
array-based
front is -1
queue is empty
array-based
front is equal to rear + 1
queue is empty