Bird
0
0
DSA Cprogramming~10 mins

Why Doubly Linked List Over Singly Linked List 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 node struct for a doubly linked list.

DSA C
typedef struct Node {
    int data;
    struct Node* next;
    struct Node* [1];
} Node;
Drag options to blanks, or click blank then click option'
Abefore
BpreviousNode
Cback
Dprev
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'previousNode' or 'back' which are not standard names.
2fill in blank
medium

Complete the code to move forward in a doubly linked list.

DSA C
current = current->[1];
Drag options to blanks, or click blank then click option'
Anext
Bprevious
Cprev
Dback
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' to move forward causes moving backward.
3fill in blank
hard

Fix the error in the code to move backward in a doubly linked list.

DSA C
current = current->[1];
Drag options to blanks, or click blank then click option'
ApreviousNode
Bnext
Cprev
Dback
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'next' moves forward, not backward.
4fill in blank
hard

Fill both blanks to insert a new node after the current node in a doubly linked list.

DSA C
newNode->next = current->[1];
newNode->[2] = current;
Drag options to blanks, or click blank then click option'
Anext
Bprev
Cprevious
Dbefore
Attempts:
3 left
💡 Hint
Common Mistakes
Swapping next and prev pointers.
5fill in blank
hard

Fill all three blanks to update pointers when inserting a new node after current in a doubly linked list.

DSA C
if (current->next != NULL) {
    current->next->[1] = newNode;
}
newNode->[3] = current->next;
current->[2] = newNode;
Drag options to blanks, or click blank then click option'
Aprev
Bnext
Attempts:
3 left
💡 Hint
Common Mistakes
Not updating the next node's prev pointer.