Skip to content

Instantly share code, notes, and snippets.

@fabianbaechli
Created April 22, 2025 14:29
Show Gist options
  • Save fabianbaechli/4093541670650fe3d7db581004b7e569 to your computer and use it in GitHub Desktop.
Save fabianbaechli/4093541670650fe3d7db581004b7e569 to your computer and use it in GitHub Desktop.
infix(struct node* p = {
if (p ≠ NULL) {
if (needParanthesis(p, false)) {
printf("(");
infix(p->lft);
printf(")");
} else {
infix(p->lft);
}
}
printf(%c", p->val);
if (needParanthesis(p, true) {
printf("(");
infix(p->rgt);
printf(")");
} else {
infix(p->rgt);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment