void SetSize(TreeNode * t) // precondition: t != NULL // postcondition: The size field of every node in the tree t // has been set to the size of that node's subtree { int leftSize = 0; // size of left subtree int rightSize = 0; // size of right subtree if (t != NULL) { SetSize(t->left); SetSize(t->right); if (t->left != NULL) leftSize = t->left->size; if (t->right != NULL) rightSize = t->right->size; t->size = leftSize + rightSize + 1; } }