Complete the code to declare a pointer to a new TreeNode.
TreeNode* root = new [1](10);
The class name for a tree node is TreeNode. We create a new node with value 10.
Complete the code to assign a new left child node with value 5 to root.
root->[1] = new TreeNode(5);
The left child pointer is named left. We assign a new node with value 5 to it.
Fix the error in the code to assign a right child node with value 15 to root.
root->[1] = new TreeNode(15);
The right child pointer is named right. Assigning a new node to right is correct.
Fill both blanks to create a left child with value 3 and a right child with value 7 for the left child of root.
root->left->[1] = new TreeNode(3); root->left->[2] = new TreeNode(7);
The left child of root gets a left child (value 3) and a right child (value 7). Use left and right pointers respectively.
Fill all three blanks to create a right child with value 20 for root, then add left and right children with values 17 and 25 to that node.
root->[1] = new TreeNode(20); root->right->[2] = new TreeNode(17); root->right->[3] = new TreeNode(25);
First, assign the right child of root (blank 1) as right. Then assign its left child (blank 2) as left and right child (blank 3) as right.