Qualcomm Interview Question for Software Engineer / Developers


Country: United States
Interview Type: Phone Interview




Comment hidden because of low score. Click to expand.
1
of 3 vote

Shallow copy: When the data in one data structure (usually class instance) is copied and created a new instance BUT only the top-level data is copied (e.g. the data belonging to the embedded references are not)

Deep copy: Object is copied in a way that all data in the references it contains (and all inside those references, etc. recursively) is copied.


E.g. if there is a class that contains 3 points (they are themselves class-instances) and a colour (not a class, just a simple enum) a shallow copy copies the referene to the 3 points and the colour creating a new instance of that class. However using this object and modifying the points data - it will modify the data in the original copy as well (well, the data that is referenced to) In this case only one new object created.

With a deep copy all three point-instances are copied by creating new instances, too, so making any change using this new object has no impact to the old object whatsoever. In this case 1+3 new objects are created.

- Selmeczy, Péter November 05, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

Also known as address copy as in this process B is attached to same memory block as A (for copying A to B). This results in situation where same data is being shared between A and B thus modifying the one will alter the other. Advantage - Execution speed is fast and does not depend on data size.

- victor November 05, 2012 | Flag Reply


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