For the following binary tree, inorder traversal yields the expression:
2017
For the following binary tree, inorder traversal yields the expression:


- A.
− + * abde f
- B.
a + b d *− ef/
- C.
abdef* / + −
- D.
a + b * d − e / f
Attempted by 742 students.
Show answer & explanation
Correct answer: D
Solution: Inorder traversal (left, root, right)
Visit the left subtree of the root (the subtree with '+' as root).
In that subtree, visit its left child: a
Then visit the '+' node itself, appending + to the expression.
Now visit the right subtree of '+' which is the '*' node: visit its left child b, then '*' (*), then its right child d. This yields "b * d" for that subtree.
Combining the left subtree gives: a + b * d
Visit the root node - and append it.
Finally visit the right subtree (the '/' node): visit left child e, then '/' (/), then right child f. This yields "e / f".
Final inorder expression: a + b * d - e / f