Complete the code to check if the current node is null during serialization.
if (root [1] null) return "#";
The code checks if the current node is null to serialize it as "#".
Complete the code to split the serialized string by commas during deserialization.
var nodes = data.Split([1]);The serialized nodes are separated by commas, so splitting by ',' gives the list of node values.
Fix the error in the recursive deserialization call to correctly build the left subtree.
root.Left = DeserializeHelper(nodes, ref [1]);The variable 'index' is used to track the current position in the nodes array during deserialization.
Fill both blanks to correctly convert string to int and advance the index during deserialization.
root.Val = int.Parse(nodes[[1]]); [2]++;
The current index is used to get the node value and then incremented to move forward.
Fill both blanks to complete the serialization method using preorder traversal.
return root.Val + "," + Serialize(root.[1]) + "," + Serialize(root.[2]);
Preorder traversal visits root, then left subtree, then right subtree. The code serializes root.Val, then left, then right.
