Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the sentence to describe a deque.
Data Structures Theory
A deque allows insertion and removal of elements from both the [1] and the [2].
Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Thinking elements can be added or removed from the middle.
Confusing deque with a stack or queue that only works on one end.
β Incorrect
A deque (double-ended queue) supports adding and removing elements from both the front and the back ends.
2fill in blank
mediumComplete the sentence to explain deque operations.
Data Structures Theory
The operation to add an element at the back of a deque is called [1]. Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Using 'pop_front' which means removing from front.
Confusing enqueue and dequeue which are queue operations.
β Incorrect
In a deque, adding an element at the back is called push_back.
3fill in blank
hardFix the error in the statement about deque removal.
Data Structures Theory
Removing an element from the front of a deque is done using [1].
Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Using 'push_front' which adds instead of removes.
Confusing 'pop_back' which removes from the back.
β Incorrect
To remove an element from the front of a deque, the correct operation is pop_front.
4fill in blank
hardFill both blanks to describe deque usage.
Data Structures Theory
A deque can be used as a [1] or a [2] because it supports insertion and removal from both ends.
Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Choosing 'list' or 'tree' which are different data structures.
Not realizing deque can behave like both stack and queue.
β Incorrect
A deque can act like a stack (LIFO) or a queue (FIFO) because it allows adding and removing elements from both ends.
5fill in blank
hardFill all three blanks to complete the Python deque example.
Data Structures Theory
from collections import [1] d = [1]() d.[2](5) # add to back d.pop[3]() # remove from front
Drag options to blanks, or click blank then click option'
Attempts:
3 left
π‘ Hint
Common Mistakes
Using
list instead of deque, which is inefficient for front operations.Using
appendleft for back or pop for front.Forgetting the specific method names in Python's deque.
β Incorrect
In Python, deque from collections is used. append(5) adds to the back, and popleft() removes from the front.