I understand the "rules" of inserting
void printTree(BTNode* node) {
if (node == NULL)
return;
printTree(node->left);
printf("%c", node->item);
printTree(node->right);
}
I understand the "rules" of inserting
void printTree(BTNode* node) {
if (node == NULL)
return;
printTree(node->left);
printf("%c", node->item);
printTree(node->right);
}
in
createExp, the right node may be build with some chars already parsed by the left node. It will happened each time the left node parses more than one char.To prevent this,
createExpshould return an info to where parsing ends. Something like this :If you need to keep
createExpTreesignature, you can flatten the recursion into an loop like that :