Adobe Interview Question for Software Engineer / Developers






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

You should not alter the list while iterating through it.

- Anonymous August 04, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

Probably, u shud be synchronizing the list l while iterating

- Anonymous August 29, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

i think u cant never do a new list() because list is an interface..

- ankit September 07, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 votes

i think u cant never do a new list() because list is an interface..

- ankit September 07, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

list can not be accessed by directly by indexes.this is a drawback of lists over other sequence containers. So list(i) is not a valid way to access.

- Anonymous September 08, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 votes

that is in c++. In java list(i) is not valid but list.getItem(i) is valid.

- Anonymous September 08, 2010 | Flag
Comment hidden because of low score. Click to expand.
0
of 0 vote

Not mentioning the syntactical rules, the problem lies in the algorithm. the algorithm wants to check all the nodes inside the list but it will not be able to in some conditions

The list nodes are being deleted inside a for loop which runs for the length of the list. this will create problems and may not iterated over the entire list which would be a bug.

for example, assume that the list has 5 nodes, so the list length is 5. let the iteration counter be equal to 3 (i=3) so that the 4th node is being checked, let it satisfy the condition and be removed so that the list length now is equal to 4. however, 'i' is 3 in current iteration. after removal, i would be incremented to 4.

now, we have only compared the 4th node with i=3, deleted it and incremented i to 4. length is also 4 since we have removed a node from the list. so now, when the condition in for loop is checked again, it says that 'i' should be less that length of list. since both are equal to 4, the flow will exit from the for loop and the last node of the list will not be checked.

The best idea is to run inside a while loop and see if the current node is the last node of the list.

- AK September 29, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@AK..good explanation

- Newbie December 28, 2010 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

@ak
decrement the i by 1 whenever we remove the item.
it will work.

- mm January 18, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Nice explanations.

- Anshul Zunke February 16, 2011 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

The iterators returned by this class's iterator and listIterator methods are fail-fast: if the list is structurally modified at any time after the iterator is created, in any way except through the iterator's own remove or add methods, the iterator will throw a ConcurrentModificationException. Thus, in the face of concurrent modification, the iterator fails quickly and cleanly, rather than risking arbitrary, non-deterministic behavior at an undetermined time in the future.

- Rinkal July 14, 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