Explain Polymorphism and Binary Trees, and How You Use AI Tools as an Engineer
Company: J.P. Morgan
Role: Software Engineer
Category: Software Engineering Fundamentals
Difficulty: medium
Interview Round: Technical Screen
In a technical round with no coding problem, the interviewer asked about computer science fundamentals and about how you use AI. Answer the three prompts below as you would aloud, with short examples. The round lasts about 25 to 30 minutes, so each answer should be precise rather than exhaustive.
### Clarifying Questions
- Is there a preferred language for code examples?
- Should the binary tree discussion include code, or stay at the level of concepts and costs?
### Part 1 — Polymorphism
Explain polymorphism. What forms does it take, how does a program decide which implementation to run, and why is it useful? Give a short code example.
```hint Decided when
Separate what the compiler decides from what is decided while the program runs.
```
#### What This Part Should Cover
- A precise definition with a small, correct code example
- Runtime polymorphism through overriding and dynamic dispatch, versus overloading and generics
- Why it matters for design: extensibility and substitutability
- Common confusions and limits
### Part 2 — Binary trees
Explain what a binary tree is. How does a binary search tree differ from a general binary tree, how can a tree be traversed, and what do the main operations cost?
```hint Insert in sorted order
Picture the shape of a binary search tree after inserting keys that arrive already sorted, and what that shape does to search time.
```
#### What This Part Should Cover
- Definitions and vocabulary: root, leaf, height, full, complete and balanced trees
- The binary search tree ordering property and what it enables
- Traversal orders and what each is used for
- Costs in the balanced and the degenerate case, and how balance is maintained
### Part 3 — Using AI
How do you use AI tools in your engineering work? Where do they help, where do you not trust them, and how do you check what they produce?
```hint One concrete example
Pick one real task and walk through how you verified the tool's output before relying on it.
```
#### What This Part Should Cover
- Concrete, specific uses rather than general enthusiasm
- How output is verified before it is relied on
- Known failure modes and risks: invented APIs, subtle bugs, security issues, confidential data
- Judgment about when not to use the tool
### What a Strong Answer Covers
- Precise definitions followed by small, correct examples
- The distinctions interviewers probe: overriding versus overloading, binary tree versus binary search tree, average versus worst case
- Complexity stated together with the condition it depends on
- A responsible, verifiable account of AI tool use
- Concise answers suited to a short conversational round
### Follow-up Questions
- How does a language implement dynamic dispatch under the hood?
- How would you check whether a binary tree is a valid binary search tree, and what is a common incorrect approach?
- How would you build a height-balanced binary search tree from a sorted array?
- An AI assistant suggests a library function that does not exist. How do you catch that kind of error systematically?
Overview: A software engineering fundamentals discussion with no coding problem: explain polymorphism with examples, describe binary trees and binary search trees with their traversals and costs, and explain how you use AI tools responsibly. It tests precise definitions, complexity reasoning and engineering judgment.