Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new node with the given value.
DSA C#
Node newNode = new Node([1]);Attempts:
3 left
💡 Hint
Common Mistakes
Using 'node' instead of the value.
Passing 'null' which creates an empty node.
Using 'head' which is the start of the list, not the new value.
✗ Incorrect
The constructor of Node requires the value to store in the node.
2fill in blank
mediumComplete the code to move the slow pointer one step forward in the linked list.
DSA C#
slow = slow[1];Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' which is for doubly linked lists.
Using 'head' which resets the pointer to the start.
Using 'value' which is data, not a pointer.
✗ Incorrect
To move forward in a singly linked list, use the 'next' pointer.
3fill in blank
hardFix the error in the while loop condition to correctly find the middle node.
DSA C#
while (fast != null && fast[1] != null) {
Attempts:
3 left
💡 Hint
Common Mistakes
Checking fast.prev which does not exist in singly linked list.
Checking fast.value which is data, not a pointer.
Checking fast.head which is invalid.
✗ Incorrect
The fast pointer moves two steps, so we check fast.next to avoid null reference.
4fill in blank
hardFill both blanks to correctly move the fast pointer two steps ahead.
DSA C#
fast = fast[1]; fast = fast[2];
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' which is not in singly linked list.
Using 'value' which is data, not a pointer.
Using 'head' which resets pointer.
✗ Incorrect
To move two steps forward, move fast to fast.next, then fast.next again.
5fill in blank
hardFill the blank to return the data of the middle node.
DSA C#
return slow[1];
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.next' which is a pointer to next node, not data.
Using '.data' which may not be the property name in this implementation.
Using '.head' which is invalid here.
✗ Incorrect
The middle node's data is accessed by the 'value' property.
