Bird
0
0
DSA Cprogramming~10 mins

Enqueue Using Linked List in DSA C - Interactive Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to create a new node for enqueue operation.

DSA C
struct Node* newNode = (struct Node*)malloc(sizeof([1]));
Drag options to blanks, or click blank then click option'
AQueue
BNode
Cint
Dstruct
Attempts:
3 left
💡 Hint
Common Mistakes
Using sizeof(int) instead of sizeof(Node).
Using sizeof(struct) which is invalid.
2fill in blank
medium

Complete the code to assign the data value to the new node.

DSA C
newNode->data = [1];
Drag options to blanks, or click blank then click option'
Avalue
BNULL
CnewNode
Ddata
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning newNode->data = data (undefined variable).
Assigning newNode->data = NULL.
3fill in blank
hard

Fix the error in linking the new node at the end of the queue.

DSA C
queue->rear->[1] = newNode;
Drag options to blanks, or click blank then click option'
Adata
Bprev
Crear
Dnext
Attempts:
3 left
💡 Hint
Common Mistakes
Using prev instead of next.
Assigning to data or rear fields.
4fill in blank
hard

Fill both blanks to update the rear pointer and set the new node's next to NULL.

DSA C
queue->rear = [1];
newNode->[2] = NULL;
Drag options to blanks, or click blank then click option'
AnewNode
Bqueue
Cnext
Dprev
Attempts:
3 left
💡 Hint
Common Mistakes
Setting rear to queue instead of newNode.
Setting newNode->prev to NULL instead of next.
5fill in blank
hard

Fill all three blanks to handle the empty queue case and enqueue the new node correctly.

DSA C
if (queue->rear == NULL) {
    queue->front = [1];
    queue->rear = [2];
} else {
    queue->rear->next = [3];
}
Drag options to blanks, or click blank then click option'
AnewNode
Bqueue
DNULL
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning rear or front to queue instead of newNode.
Assigning rear->next to NULL instead of newNode.