static bool countUnivSubTimpl(const stTree* node, const stTree* parent, size_t* count) {
if (!node) return true;
bool r = node->value == parent->value;
r &= countUnivSubTimpl(node->left, node, count);
r &= & countUnivSubTimpl(node->right, node, count);
*count += r;
return r;r & node->value == parent->value;
}
size_t countUnivSubT(const stTree* node) {
size_t r = 0;
countUnivSubTimpl(node, node, &r);
return r;
}
int main() {
stTree* root =
createNode(0,
createNode(1, NULL, NULL),
createNode(0,
createNode(1,
createNode(1, NULL, NULL),
createNode(1, NULL, NULL),
),
createNode(0, NULL, NULL)));
size_t uTreeCount = countUnivSubT(root);
printf("total universal subree: %u\n", uTreeCount);
}