Complete the code to initialize the current node for Morris Traversal.
current = [1]The traversal starts from the root node, so we assign current = root.
Complete the condition to check if the current node has a left child.
if current.[1] is None:
We check if the current node has a left child by testing current.left.
Fix the error in the loop that finds the rightmost node in the left subtree.
while predecessor.[1] is not None and predecessor.right != current:
The loop moves to the right child of the predecessor to find the rightmost node.
Fill both blanks to create and remove the temporary thread in Morris Traversal.
if predecessor.right is None: predecessor.right = [1] current = [2]
We create a thread by pointing predecessor.right to current, then move current to its left child.
Fill all three blanks to remove the thread and move current to the right child.
else: predecessor.right = [1] print(current.[2]) current = [3]
We remove the thread by setting predecessor.right to None, print the current node's value, then move current to its right child.
