Simplify an Arithmetic Expression Tree with Constant Folding and Identities

Quick Overview

Given the abstract syntax tree of an arithmetic expression as a binary tree, write a traversal that returns an equivalent simplified tree using constant folding and algebraic identities. It tests recursive tree processing, cascading rewrites, correct handling of non-commutative operators and recursion-depth limits.

Simplify an Arithmetic Expression Tree with Constant Folding and Identities

Company: Amazon

Role: Software Engineer

Category: Software Engineering Fundamentals

Difficulty: medium

Interview Round: Onsite

Overview: Given the abstract syntax tree of an arithmetic expression as a binary tree, write a traversal that returns an equivalent simplified tree using constant folding and algebraic identities. It tests recursive tree processing, cascading rewrites, correct handling of non-commutative operators and recursion-depth limits.

Amazon logo
Amazon
Sep 5, 2026
mediumSoftware EngineerOnsiteSoftware Engineering Fundamentals
3
0
Loading...