Complete the sentence to describe a deque.
A deque allows insertion and removal of elements from both the [1] and the [2].
A deque (double-ended queue) supports adding and removing elements from both the front and the back ends.
Complete the sentence to explain deque operations.
The operation to add an element at the back of a deque is called [1].In a deque, adding an element at the back is called push_back.
Fix the error in the statement about deque removal.
Removing an element from the front of a deque is done using [1].
To remove an element from the front of a deque, the correct operation is pop_front.
Fill both blanks to describe deque usage.
A deque can be used as a [1] or a [2] because it supports insertion and removal from both ends.
A deque can act like a stack (LIFO) or a queue (FIFO) because it allows adding and removing elements from both ends.
Fill all three blanks to complete the Python deque example.
from collections import [1] d = [1]() d.[2](5) # add to back d.pop[3]() # remove from front
list instead of deque, which is inefficient for front operations.appendleft for back or pop for front.In Python, deque from collections is used. append(5) adds to the back, and popleft() removes from the front.
