Amazon Interview Question for Software Engineer / Developers






Comment hidden because of low score. Click to expand.
2
of 2 vote

A shallow copy of an object copies all of the member field values. This works well if the fields are values, but may not be what you want for fields that point to dynamically allocated memory. The pointer will be copied. but the memory it points to will not be copied -- the field in both the original object and the copy will then point to the same dynamically allocated memory, which is not usually what you want. The default copy constructor and assignment operator make shallow copies.

A deep copy copies all fields, and makes copies of dynamically allocated memory pointed to by the fields. To make a deep copy, you must write a copy constructor and overload the assignment operator, otherwise the copy will point to the original, with disasterous consequences.

- creation December 09, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

# A shallow copy generally means copying bits from one memory block to another.
# A deep copy generally means recursively copying variables in a nested structure, or objects in a nested object.

1. http://tinyurl.com/llpes6
2. http://portal.acm.org/citation.cfm?doid=782941.782990

- LLOLer August 24, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

HardCopy is copying the values from one structure to another.If there are pointers in the structure, then the second structure also points to the same pointer location as in the first one.

Shallow copy is copying bit by bit, If there are pointers in the structure to be copied,then a new memory location is created and data is copied to that location.

- Jo August 24, 2009 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hard copy - a print-out.

Shallow copy - a bit by bit copy of data type's instance without copying aggregated structure or class instances.

- Anonymous September 29, 2009 | Flag


Add a Comment
Name:

Writing Code? Surround your code with {{{ and }}} to preserve whitespace.

Books

is a comprehensive book on getting a job at a top tech company, while focuses on dev interviews and does this for PMs.

Learn More

Videos

CareerCup's interview videos give you a real-life look at technical interviews. In these unscripted videos, watch how other candidates handle tough questions and how the interviewer thinks about their performance.

Learn More

Resume Review

Most engineers make critical mistakes on their resumes -- we can fix your resume with our custom resume review service. And, we use fellow engineers as our resume reviewers, so you can be sure that we "get" what you're saying.

Learn More

Mock Interviews

Our Mock Interviews will be conducted "in character" just like a real interview, and can focus on whatever topics you want. All our interviewers have worked for Microsoft, Google or Amazon, you know you'll get a true-to-life experience.

Learn More