← Mithril Interview Insights

Mithril·Software Engineer·Technical Phone Screen·Intermediate

Intermediate
Jun 2026

Summary

Had a technical round at Mithril for a software engineer role. The main problem was building a parser for arithmetic and logical expressions that outputs operation triads, basically the same intermediate representation compilers use internally. Pretty niche problem and I wasn't fully prepared for how much ground it covered.

Questions Asked (1)

Q1

Design and implement a system that parses arithmetic and logical expressions into a sequence of operation triads (op, operand1, operand2), correctly handling operator precedence, associativity, and parentheses.

Algorithms & Data StructuresSystem DesignTechnical Trade-offs
Author's notes

I know enough about compilers to recognize three-address code but actually implementing a parser from scratch under pressure is a different story.

Create a free account to read the full note

AI HintsAI Generated

Suggested Approach

Start by clarifying requirements and constraints, then outline a two-phase approach: tokenization and parsing using the shunting-yard algorithm to produce postfix notation, followed by conversion to triads. Emphasize handling of precedence, associativity, and parentheses, and discuss trade-offs between different parsing techniques.

Pro tip: Demonstrate awareness of real-world complexities like unary operators, function calls, and error handling, and mention how the triad representation can be extended for optimization or code generation.

1. Clarify Requirements and Constraints

Ask about the expected input format, supported operators, error handling, and performance requirements. Confirm whether the output should be a list of triads and if any specific ordering is required.

2. Choose Parsing Strategy

Decide between recursive descent, shunting-yard, or other algorithms based on requirements. Explain why shunting-yard is suitable for handling precedence and associativity with parentheses.

3. Design Tokenization and Parsing

Describe how to tokenize the input into numbers, operators, and parentheses. Then apply the shunting-yard algorithm to convert to postfix notation, managing operator stack and output queue.

4. Convert Postfix to Triads

Process the postfix expression using a stack to build triads. For each operator, pop two operands (or operand references) and create a triad, pushing a reference to the result for subsequent operations.

5. Discuss Trade-offs and Extensions

Compare your approach with alternatives like recursive descent or AST-based methods. Mention how to handle unary operators, function calls, and error recovery, and how triads facilitate optimization.

Key Points to Mention

  • Operator precedence and associativity rules (e.g., * before +, left-associative for most binary operators)
  • Handling parentheses by pushing/popping from the operator stack
  • Shunting-yard algorithm details: operator stack, output queue, and precedence comparison
  • Triad representation: (op, operand1, operand2) where operands can be values or references to previous triads
  • Error handling for mismatched parentheses, invalid tokens, or division by zero
  • Trade-offs: shunting-yard vs recursive descent vs AST; time/space complexity; extensibility for unary operators and functions

AI-generated suggestions, not part of the candidate's original notes. May be inaccurate — verify before relying on them.