← Mithril Interview Insights

Mithril·Software Engineer·Technical Phone Screen·Intermediate

IntermediatePrefer not to say
Jun 2026

Summary

Mithril had me implement an Operation Triads Parsing system for a software engineering round, basically building a mini compiler IR from scratch. Pretty niche problem, not something you'd prep for on Leetcode.

Questions Asked (1)

Q1

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

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

This one took me a minute to even understand what they wanted.

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 or recursive descent to handle precedence and associativity. Finally, discuss how to generate operation triads and address edge cases like parentheses and unary operators.

Pro tip: Mention that you would use a stack-based algorithm like shunting-yard for efficiency, but also note recursive descent as a more extensible alternative for complex grammars. Emphasize testing with edge cases like nested parentheses and mixed operators to demonstrate thoroughness.

1. Clarify Requirements and Constraints

Ask about the expected input format, operator set, and whether the output should be a list of triads or a graph. Confirm handling of unary operators and error cases.

2. Design Tokenization and Parsing Strategy

Describe how to tokenize the input into operands and operators, then choose a parsing method (e.g., shunting-yard or recursive descent) that respects precedence and associativity.

3. Implement Parsing with Precedence and Parentheses

Explain how the chosen algorithm handles parentheses and operator precedence, possibly using stacks for operators and operands. Mention associativity rules (left vs right).

4. Generate Operation Triads

Detail how to produce triads (op, operand1, operand2) during or after parsing, ensuring correct order of operations. Discuss representation (e.g., list of tuples or objects).

5. Test and Validate with Edge Cases

Outline a testing plan covering nested parentheses, mixed operators, unary operators, and invalid inputs. Mention complexity analysis (time and space).

Key Points to Mention

  • Operator precedence and associativity rules (e.g., * before +, left-associative for most binary operators).
  • Use of stacks for parsing (shunting-yard) or recursive descent with grammar rules.
  • Handling of parentheses to override precedence.
  • Generation of triads in postfix or infix order, ensuring correct operand order.
  • Edge cases: unary minus, nested parentheses, invalid expressions, and error handling.
  • Time and space complexity: O(n) for parsing with stacks, O(n) space for output triads.

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