2nd Exam Flashcards
Q: What does the QFront() operation return in a queue?
A: The QFront() operation returns the first element of the queue.
Q: When does a circular queue become full?
A: A circular queue becomes full when the front is greater than the rear by 1.
Q: When is a circular queue empty?
A: A circular queue is empty when both the front and rear are equal to -1.
Q: What policy does a queue implement?
A: A queue implements the first-in, first-out (FIFO) policy.
Q: What is the inchworm effect in queue implementation?
A: The inchworm effect is noticeable when implementing array-based queues.
Q: What operation returns the first element of a queue?
A: The Queue.Front() operation returns the first element.
Q: What is the solution to the problem encountered with array-based queues?
A: A circular queue is the solution for problems encountered with array-based queues.
Q: What does Tenqueue(QFront() * 2) do?
A: It correctly inserts a value that is 2 times the value of the first element of the queue named T.
Q: What does the Dequeue() operation do in a queue?
A: The Dequeue() operation removes the element at the front of the queue.
Q: What does the head pointer in a queue provide?
A: The head pointer provides information about the memory address location.
Q: When does a circular queue become full (alternate condition)?
A: A circular queue becomes full when the front is equal to the rear.
Q: What happens to the next oldest element after a Dequeue() operation?
A: The next oldest element becomes the front element after a Dequeue().
Q: What does the Dequeue() operation remove in a queue?
A: The Dequeue() operation removes the element at the front of the queue.
Q: What type of data structure is a queue?
A: A queue is a linear data structure that follows the First In First Out (FIFO) order.
Q: What is a real-world example of a queue?
A: A line of customers waiting for service at a bank.
Q: What happens to a newly inserted element in a circular queue after an Enqueue() on an empty queue?
A: The new element becomes the rear element.
Q: How does the queue differ from a stack?
A: In a stack, the most recently added item is removed first, while in a queue, the least recently added item is removed first.
Q: What is the front or head in a queue?
A: It is the end of the queue where all deletions (removals) are made.
Q: What operation inserts an element at the rear of a queue?
A: The Enqueue operation.
Q: What is the rear or tail in a queue?
A: It is the end of the queue where all insertions are made.
Q: What is queue overflow?
A: Queue overflow occurs when you try to insert an element into a full queue.
Q: What operation removes an element from the front of a queue?
A: The Dequeue operation.
Q: What are two operations that observe the state of a queue?
A: Full() (returns 1 if the queue is full) and Empty() (returns 1 if the queue is empty).
Q: What is queue underflow?
A: Queue underflow occurs when you try to remove an element from an empty queue.