После поиска в Google, я не смог найти итеративный подход, чтобы проверить, является ли дерево двоичного поиска деревом сумм.
Если у кого-то есть ответ, пожалуйста, опубликуйте его здесь.
Вот ответ на GeeksForGeeks ссылка .
int isSumTree(struct node* node) { int ls, rs; /* If node is NULL or it's a leaf node then return true */ if(node == NULL || (node->left == NULL && node->right == NULL)) return 1; /* Get sum of nodes in left and right subtrees */ ls = sum(node->left); rs = sum(node->right); /* if the node and both of its children satisfy the property return 1 else 0*/ if((node->data == ls + rs)&& isSumTree(node->left) && isSumTree(node->right)) return 1; return 0; }