Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to declare the queue node pointer for BFS traversal.
DSA C
struct Node* [1] = NULL;Attempts:
3 left
💡 Hint
Common Mistakes
Using 'root' which is the tree root, not the queue node.
Using 'temp' or 'current' which are used later, not for queue declaration.
✗ Incorrect
We declare a pointer named queueNode to use as the queue node in BFS.
2fill in blank
mediumComplete the code to enqueue the root node into the queue.
DSA C
enqueue(queue, [1]);Attempts:
3 left
💡 Hint
Common Mistakes
Enqueuing NULL which causes no traversal.
Enqueuing temp or queueNode which are used later.
✗ Incorrect
We enqueue the root node to start BFS traversal.
3fill in blank
hardFix the error in the condition to check if the queue is empty.
DSA C
while (queue->front != [1]) {
Attempts:
3 left
💡 Hint
Common Mistakes
Comparing front to rear which is incorrect for empty check.
Using -1 which is not a pointer value.
✗ Incorrect
The queue is empty when front is NULL.
4fill in blank
hardFill both blanks to correctly assign left and right children to the queue.
DSA C
if (temp->left != [1]) enqueue(queue, temp->left); if (temp->right != [2]) enqueue(queue, temp->right);
Attempts:
3 left
💡 Hint
Common Mistakes
Checking against root or temp which are not child pointers.
Using queue which is the queue structure, not a node pointer.
✗ Incorrect
We check if left and right children are not NULL before enqueuing.
5fill in blank
hardFill all three blanks to dequeue the current node and print its data.
DSA C
[2] = dequeue(queue); [3] = [2]; printf("%d ", [1]->data);
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing temp and queueNode in wrong order.
Printing or dequeuing wrong variables.
✗ Incorrect
We dequeue into queueNode, assign temp to queueNode, then print queueNode data.
