I've decided to try to teach myself how to program and am working my way through the Python version of "How to think like a computer scientist". Have tried to hold off asking questions about the exercises (since the whole point is to solve them myself) but this one has me stumped.

In chapter 20, after introducing Inorder traversal (working with the expression 1+2\*3) and a function to traverse the tree and print each node, it then asks: "modify printTreeInorder so that it puts parentheses round every operator and pair of operands". I'm thus assuming the output should look like (1+(2)\*3).

I struggle with recursive functions in general and am struggling with this. I tried inserting parentheses before and after the left and right calls, which didn't work, and now I'm thinking that the function stack will be five deep - don't see how I get to two pairs of parentheses out of that.

Feels like a cop-out asking, but can anyone put me on the right track with this?

Thanks,

Billy.