Amazon Interview Question for SDE1s


Team: Amazon Fresh
Country: United States
Interview Type: Phone Interview




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

Arrays advantages:
- O(1) lookup time on any element regardless of relative position within the array
- No element in the array has any other element as a dependency, all can be edited or manipulated independently
- (In some languages) fixed size in memory, usually contiguous
- if ordered for whatever type of values are contained, lookup time goes from O(n) down to O(log n), whereas linked lists are always O(n) search

Linked Lists:
- Flexible data structure size, can grow or shrink as needed, better use of memory space
- elements in list are aware of/affected by other elements because of the linking, making this ideal for situations where you need to keep track of order/relation of elements (think stacks, queues)
- deletion of elements does not create blank gaps in the list, you can traverse the entire length and only need to be concerned about encountering a null pointer at the end

- Javeed March 12, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Hello ? list supports fast (O(1) ) insertion and deletion at any position, array only support fast insertion and deletion at the end (all other positions would take O(N) time).

- gen-y-s March 12, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Actually, arrays cannot insert or delete at the end. To increase or the decrease the size, you need to copy the array..

- pbmeldas March 13, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

Arrays actually do not have fast insertion or deletion at the end.
You would need to create a new array with +1 or -1 size and copy all the elements to insert or remove in the end.
Linked list also does not have O(1) insertion because linked lists need to traverse down a certain amount and then create a new link, which has the worst complexity of O(n)

- meldas March 13, 2015 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

With modern architectures memory locality is a huge plus for arrays too. over 10x speedup when reading sequential values compared to linked lists.

- Anonymous March 14, 2015 | Flag
Comment hidden because of low score. Click to expand.
Comment hidden because of low score. Click to expand.
1
of 1 vote

Its not search time but lookup time is O(1)

- newspecies March 12, 2015 | 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