What is the difference between a deep copy and a shallow copy?
What is the difference between a deep copy and a shallow copy?
Approach: Compare copying references vs copying actual values/objects recursively.
A shallow copy copies only the object's top-level fields (references remain shared). A deep copy recursively copies the object and all objects it references.
Follow-up: Which one is faster to perform?
Key concepts: references, object graph.