Bird
0
0
DSA Cprogramming~10 mins

Why Linked List Exists and What Problem It Solves in DSA C - Test Your Knowledge

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

Complete the code to declare a pointer to the next node in a linked list node structure.

DSA C
struct Node {
    int data;
    struct Node* [1];
};
Drag options to blanks, or click blank then click option'
Anext
Bprev
Clink
Dpointer
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' which is for doubly linked lists.
Using generic names like 'pointer' which are unclear.
2fill in blank
medium

Complete the code to create a new node dynamically in a linked list.

DSA C
struct Node* newNode = (struct Node*) malloc(sizeof([1]));
Drag options to blanks, or click blank then click option'
Astruct
BNode
Cnode
Dint
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'node' which is undefined.
Using 'int' which is the wrong type.
3fill in blank
hard

Fix the error in the code to properly link a new node to the existing linked list.

DSA C
newNode->[1] = head;
Drag options to blanks, or click blank then click option'
Apointer
Bprev
Clink
Dnext
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' which is for doubly linked lists.
Using undefined pointer names like 'link' or 'pointer'.
4fill in blank
hard

Fill both blanks to complete the function that inserts a new node at the beginning of the linked list.

DSA C
void insertAtFront(struct Node** head_ref, int new_data) {
    struct Node* newNode = (struct Node*) malloc(sizeof([1]));
    newNode->data = new_data;
    newNode->[2] = *head_ref;
    *head_ref = newNode;
}
Drag options to blanks, or click blank then click option'
ANode
Bnode
Cnext
Dprev
Attempts:
3 left
💡 Hint
Common Mistakes
Using lowercase 'node' which is undefined.
Using 'prev' which is for doubly linked lists.
5fill in blank
hard

Fill all three blanks to complete the function that prints all elements of a linked list.

DSA C
void printList(struct Node* [1]) {
    struct Node* [2] = [3];
    while (temp != NULL) {
        printf("%d -> ", temp->data);
        temp = temp->next;
    }
    printf("NULL\n");
}
Drag options to blanks, or click blank then click option'
Ahead
Btemp
Ccurrent
Dnode
Attempts:
3 left
💡 Hint
Common Mistakes
Using the same name for parameter and temp pointer causing confusion.
Using undefined variable names in the loop.