Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to add an element at the rear of the queue.
DSA C
queue->rear = (queue->rear + 1) % queue->capacity; queue->array[queue->rear] = [1];
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'rear' or 'front' instead of the item variable.
Assigning to the wrong index in the array.
✗ Incorrect
The item to be enqueued is assigned to the position at rear index.
2fill in blank
mediumComplete the code to check if the queue is full before enqueue.
DSA C
if ((queue->rear + 1) % queue->capacity == [1]) { return; // Queue is full }
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing with rear or capacity instead of front.
Using incorrect modulo logic.
✗ Incorrect
The queue is full when the next rear position equals the front index.
3fill in blank
hardFix the error in updating the rear index after enqueue.
DSA C
queue->rear = (queue->rear [1] 1) % queue->capacity;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using subtraction or multiplication instead of addition.
Forgetting modulo operation.
✗ Incorrect
The rear index should be incremented by 1 modulo capacity.
4fill in blank
hardFill both blanks to correctly enqueue an item and update size.
DSA C
queue->rear = (queue->rear [1] 1) % queue->capacity; queue->array[queue->rear] = [2]; queue->size++;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' for rear update.
Assigning wrong variable to array.
✗ Incorrect
Increment rear by 1 and assign the item to the rear position.
5fill in blank
hardFill all three blanks to enqueue an item safely with full check.
DSA C
if ((queue->rear [1] 1) % queue->capacity == queue->front) { return; // Queue full } queue->rear = (queue->rear [2] 1) % queue->capacity; queue->array[queue->rear] = [3]; queue->size++;
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '-' instead of '+' in condition or update.
Assigning wrong variable to array.
✗ Incorrect
Check if next rear equals front, then increment rear and assign item.
