Amazon Phone Screen | SDE 2 | Seattle
Anonymous User
2708

Question Arithmetic Expression Tree (AET) is a specific kind of a binary tree used to represent expressions.
Each node of a binary expression tree has zero or two children.

         (/)
         / \
        /   \
      (*)   (4)
      / \
     /   \
   (2)   (+)
         / \
        /   \
      (3)   (Avg)
            / \\
           /   \\
         (6)   (2) (3)
         
        (/)
         / \
        /   \
      (8)   (4)

Design and code a data structure to represent arbitrarily large and complex arithmetic expressions.
Consider maintainability and extensibility of your structure.
Implement evaluate.

I was given this for a n-ary tree. I wanted to understand how these binary operators work for an n-ary tree.

Could someone explain how to do this from string -> tree-> evaluate expression.

Comments (6)