Adobe Interview Question






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

private static void printDLLReverse(DLLNode head) {
		DLLNode current=head;
		DLLNode prev=head;
		
		while(current!=null)
		{
			prev=current;
			current=current.getNext();
		}
		
		while(prev!=null)
		{
			System.out.println(prev.getData());
			prev=prev.getPrevious();
		}
	}

- Vir Pratap Uttam May 08, 2015 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

node structure ->

1. previous node link called previous
2. next node link called next
3. data
---------------

Algo:
1. start
2. set temp to next
3. set next to prev
4. set prev to temp
5. advance current position (var pointing to the current position in the list) to next node
6. start from step 2 again

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

node structure ->

1. previous node link called previous
2. next node link called next
3. data
---------------

Algo:
1. start
2. set temp to next
3. set next to prev
4. set prev to temp
5. advance current position (var pointing to the current position in the list) to next node
6. start from step 2 again

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

dll * reverseDoubleLinkList(dll* x)
{
if(x == NULL)
return x;

dll * tmp = x->prev;
x->prev = x->next;
x->next = tmp;

if(x->prev)
return reverseDoubleLinkList(x->prev);
else
return x;


}

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

Change head of link list to last node and link list is in reversed

- Santosh March 15, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

Best way to reverse DLL is to swap next and prev of each node. And at the end give *hRef to last node.

- Nizam March 04, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

def reverseDoublyLinkedList(head):
    # head far left end, 0 or 1 node
    if head == None or (head.next==None and head.back==None):
        return

    cur = head
    # while there is another node to the right. swap the pointer values, assumes valid lists.
    while cur:
        tmp = cur.next
        cur.next = cur.back
        cur.back = tmp
        cur = tmp

- BD October 27, 2014 | Flag Reply
Comment hidden because of low score. Click to expand.
-1
of 1 vote

why to reverse?? just go to end and back track

do like this

#define next prev
#define prev next
#define head tail
#define tail head

now use normal linklist traversal programs

- anony September 14, 2010 | 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