Complete the code to move to the left child of the current node.
current = current->[1];The Morris traversal moves to the left child to find the inorder predecessor.
Complete the code to find the inorder predecessor of the current node.
predecessor = current->left; while (predecessor->[1] != nullptr && predecessor->[1] != current) { predecessor = predecessor->[1]; }
The inorder predecessor is the rightmost node in the left subtree, so we move right repeatedly.
Fix the error in the condition to check if the predecessor's right pointer is null.
if (predecessor->[1] == nullptr) { predecessor->right = current; current = current->left; }
The Morris traversal uses the right pointer of the predecessor to create a temporary link to the current node.
Fill both blanks to correctly remove the temporary link and move to the right subtree.
else { predecessor->[1] = nullptr; [2]; }
We remove the temporary link by setting predecessor->right to nullptr and then move to the right subtree.
Fill all three blanks to print the current node's data and move to the right child.
std::cout << current->[1] << " "; current = current->[2]; // Loop continues until current is [3]
Print the data of the current node, move to the right child, and continue until current is nullptr.