Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to create a new node with the given data.
DSA Python
new_node = Node([1]) Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using head or tail instead of data when creating the new node.
Passing None instead of data.
✗ Incorrect
We create a new node by passing the data value to the Node constructor.
2fill in blank
mediumComplete the code to link the new node to the current head node.
DSA Python
new_node.next = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Pointing new_node.next to tail or None instead of head.
Pointing new_node.next to itself.
✗ Incorrect
The new node should point to the current head to insert at the beginning.
3fill in blank
hardFix the error in updating the tail's next pointer to the new node.
DSA Python
tail.next = [1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Setting tail.next to head or None breaks the circular link.
Setting tail.next to tail causes a loop on tail only.
✗ Incorrect
The tail's next should point to the new node to maintain circularity.
4fill in blank
hardFill both blanks to update the head pointer and handle empty list case.
DSA Python
if head is None: head = [1] tail = [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Assigning head or tail to None instead of new_node.
Assigning head and tail to different nodes.
✗ Incorrect
When the list is empty, head and tail both point to the new node.
5fill in blank
hardFill all three blanks to complete the insert at beginning function.
DSA Python
def insert_at_beginning(head, tail, data): new_node = Node([1]) if head is None: head = new_node tail = new_node tail.next = [2] else: new_node.next = head tail.next = [3] head = new_node return head, tail
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using head instead of new_node for tail.next.
Not updating tail.next to new_node breaks circular link.
Returning wrong variables or missing return.
✗ Incorrect
We create new_node with data, tail.next points to new_node to keep circular link, and update tail.next to new_node when list is not empty.