Amazon Interview Question for Software Engineer / Developers


Country: United States
Interview Type: In-Person




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

According to Cracking the code interview, the solution doesn't recursively delete the sub-directories and files, it just calls parent.remove(entry), which will remove the given entry from its parent's list. Is this the right way to do it? I thought we are supposed to delete all of its sub-directories and files before we go to its parent and move it from the list.

- Guy January 29, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

think of it as cutting a tree at a particular node. you end up removing entire subtree rooted at that node. so i guess the one mentioned by book is correct and efficient approach

- confused_banda January 30, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

So if I just remove a directory by simply removing it from its parent's sub-directories list, that would automatically remove all if its sub-directories and sub files too? Don't they still exist in heap?

- Guy January 30, 2014 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

with no references made to the root of the subtree whose reference fom its parent has been removed, it would become a candidate for garbage collection and would eventually be wiped ou of heap by the garbage collection routine

- Anonymous February 02, 2014 | 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