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);
}
Copyright © 2021 Jogjafile Inc.
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,
createExp
should return an info to where parsing ends. Something like this :If you need to keep
createExpTree
signature, you can flatten the recursion into an loop like that :