Expression trees
Expression trees provide an example for different applications of in-order and post-order traversal. We also introduce reverse Polish notation or RPN, and stack calculators.
Expression Trees / Postfix / RPN (6:10)
Additional reading:
And here’s a cool HP-35 RPN calculator emulator (at least, I think it’s cool):
Resources
Comprehension check
Consider this expression tree.
- What is the expression yielded by post-order traversal?
- What is the evaluation of this expression?
Answer (expression): + ᄅƃol % / ㄥ 0ㄥ + 8 0Ɛ ᄅƃol + - ᄅƖ 8 x ᄅƖ Ɛ
Answer (numeric): 8
Original author: Clayton Cafiero < [given name] DOT [surname] AT uvm DOT edu >
No generative AI was used in producing this material. This was written the old-fashioned way.
All materials copyright © 2020–2023, ̽̽. All rights reserved.