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 the data value.
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 check if the list is empty.
DSA Python
if [1] is None:
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Checking new_node instead of head.
Checking tail instead of head.
✗ Incorrect
If head is None, the list is empty.
3fill in blank
hardFix the error in the code to update the tail's next pointer.
DSA Python
tail.[1] = new_node Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'prev' instead of 'next'.
Trying to assign to 'data' or 'head'.
✗ Incorrect
The tail's next pointer should point to the new node.
4fill in blank
hardFill both blanks to update the new node's previous pointer and move the tail.
DSA Python
new_node.[1] = tail tail = [2]
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'next' instead of 'prev' for the new node.
Not updating tail to the new node.
✗ Incorrect
The new node's prev points to the old tail, then tail moves to new_node.
5fill in blank
hardFill all three blanks to complete the insert_at_end function.
DSA Python
def insert_at_end(head, tail, data): new_node = Node([1]) if head is None: head = new_node tail = new_node else: tail.[2] = new_node new_node.[3] = tail tail = new_node return head, tail
Drag options to blanks, or click blank then click option'
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up next and prev pointers.
Not updating tail after insertion.
Passing wrong value to Node constructor.
✗ Incorrect
We create new_node with data, link tail.next to new_node, new_node.prev to tail, then update tail.