Explain Polymorphism and Binary Trees, and How You Use AI Tools as an Engineer
J.P. MorganSoftware Engineer · Technical ScreenLast updated
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.
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.
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?
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?
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
Hints
Hint 1
Decided when: Separate what the compiler decides from what is decided while the program runs.
Hint 2
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.
Hint 3
One concrete example: Pick one real task and walk through how you verified the tool's output before relying on it.
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?
Solution walkthrough is for members
Get the full walkthrough with reference code and complexity analysis, plus Kitty Coach at 300 messages a day. Hints, the code runner and community answers stay free.