Amazon Interview Question for Software Engineer / Developers






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

Insertion:
----------
1) Insertion at end = O(n) if tail pointer is not given.
2) Insertion at end = O(1) if tail pointer is given.
3) Insertion at middle = O(n) if index (or a node-value) is given.
4) Insertion at middle = O(1) if address is given.
5) Insertion at the start = O(1) always.

Deletion:
---------
1) Deletion with a value or an index = O(n).
2) Deletion with a given address = O(1). Tricky method.
3) Deletion of last node = O(n) with no tail pointer.
4) Deletion of last node = O(1) with a tail pointer.
5) Deletion of first node = O(1) always.

Searching:
----------
O(n) always. Best case is O(1).

Finding a loop = O(n).

Reversing a linked list = O(n).

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

Complexity for deletion will be O(n) and complexity for insertion will be O(1).

- B April 28, 2007 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Insertion and deletion takes O(1), however searching for a particular node takes O(n)

- zdmytriv January 29, 2008 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

inserting(insert in the p'th position) and deleting(a particular node) involves searching. So both takes O(n).

Only appending takes O(1).

correct me if I am wrong.

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

Hi Helper.
Could you plz explain how Deletion with a given address = O(1).

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

copy the content of the next node, delete the next node instead

- chaos January 25, 2010 | 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