Practice - 5 Tasks
Answer the questions below
1fill in blank
easyComplete the code to move to the next node in the circular linked list.
DSA Python
current = head
current = current[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.prev' instead of '.next' to move forward.
Using attributes that don't exist like '.child' or '.parent'.
✗ Incorrect
In a circular linked list, each node points to the next node using the 'next' attribute.
2fill in blank
mediumComplete the code to check if the list has only one node.
DSA Python
if head[1] head.next:
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '!=' which checks for inequality instead of equality.
Using comparison operators like '>' or '<' which are not valid for node references.
✗ Incorrect
If head is equal to head.next, it means the list has only one node pointing to itself.
3fill in blank
hardFix the error in the code to correctly delete the head node from the circular linked list.
DSA Python
head.data = head.next.data
head.next = head[1] Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Linking head.next to head.next which causes no change.
Using '.prev' which is not relevant here.
Using '.next.prev' which is invalid in this context.
✗ Incorrect
To delete the head node, copy data from the next node and link head.next to head.next.next to skip the deleted node.
4fill in blank
hardFill both blanks to correctly find the node before the one to delete and update links.
DSA Python
prev = head while prev.next[1] != current: prev = prev.next prev.next = current[2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using '.prev' which is not used in singly linked circular lists.
Linking prev.next to current.prev which is invalid.
Incorrect loop condition causing infinite loops.
✗ Incorrect
To find the node before current, move while prev.next != current. Then link prev.next to current.next to remove current.
5fill in blank
hardFill all three blanks to complete the function that deletes a node with given key from circular linked list.
DSA Python
def delete_node(head, key): if head is None: return None current = head prev = None while True: if current.data == [1]: if prev is not None: prev.next = current[2] else: head = current[3] return head prev = current current = current.next if current == head: break return head
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using wrong variable names for key comparison.
Not updating head when deleting the head node.
Incorrectly linking nodes causing broken list.
✗ Incorrect
Check if current.data equals key. If deleting non-head node, link prev.next to current.next. If deleting head, update head to head.next.