Adobe Interview Question for Software Engineer / Developers


Country: India
Interview Type: Written Test




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

simple, just to traverse through the list and swap next, prev pointer for each item.

- Anonymous April 16, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
1
of 1 vote

void reverse(NODE **head)
{
    NODE *c = NULL, *temp = NULL;
    if(*head == NULL)
         return;
    while(*head)
    {
         temp = (*head)->next;
         (*head)->next = c;
         (*head)->prev = temp;
         c = *head;
         *head = temp;
     }
     *head = c;
}

- rising April 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 2 vote

void reverse(node *head)
{
node *current,*temp;
temp = NULL;
current = head;
while(current)
{
current->prev = current->next;
current->next=temp;
temp = current;
current = current->prev;
}
*head = temp;
}

- rohit April 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

//Write a function for reversing a doubly linked list.

#include<stdio.h>

struct node *head;

struct node
{
int val;
struct node *next;
struct node *prev;
};

void insert(int x, struct node *head)
{
struct node *p;
struct node *t = (struct node*) malloc (sizeof(struct node));
t->val = x;
t->next = t->prev = NULL;

p = head;
while(p->next != NULL)
{
p = p->next;
}
t->prev = p;
p->next = t;
}

void reverse(struct node *head)
{
struct node *p,*temp;
p = head;
while(p != NULL)
{
temp = p->prev;
p->prev = p->next;
p->next = temp;
p = p->prev;
}
head = temp->prev;
printf("\nReversed Values in the linked list are :\n");
p = head;
while(p != NULL)
{
printf("%d\t",p->val);
p = p->next;
}
}

void display(struct node *head)
{
struct node *p;
p = head;
while(p != NULL)
{
printf("%d\t",p->val);
p = p->next;
}
}

int main()
{
head = (struct node*) malloc (sizeof(struct node));
head->next = head->prev = NULL;
head->val = 4;
insert(5,head);
insert(6,head);
insert(7,head);
printf("\nValues in the linked list are :\n");
display(head);
reverse(head);
}

- pd April 14, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

#include<stdio.h>
#include<malloc.h>

struct node
{
int data;
struct node *prev;
struct node * next;
};

void append(struct node **,int);
void display(struct node *);
void reverse( struct node **);

int main()
{
struct node *p;
p=NULL;

append(&p,21);
append(&p,31);
append(&p,41);
append(&p,51);
append(&p,61);

display(p);
reverse(&p);
display(p);

return 0;
}

void append(struct node **q, int num)
{
struct node *temp,*r;
if (*q==NULL)
{
temp=(struct node *)malloc(sizeof(struct node*));
temp->data=num;
temp->prev=NULL;
temp->next=NULL;
*q=temp;
}
else
{
temp=*q;

while(temp->next!=NULL)
temp=temp->next;

r=(struct node *)malloc(sizeof(struct node *));
r->data=num;
temp->next=r;
r->next=NULL;
r->prev=temp;
}
}

void display(struct node *q)
{
while(q!=NULL)
{
printf("%d \t",q->data);
q=q->next;
}
printf("\n");
}

void reverse(struct node **q)
{
struct node *temp,*current;
current=*q;
temp=NULL;
while(current!=NULL)
{
current->prev=current->next;
current->next=temp;
temp=current;
current=current->prev;
}
*q=temp;

}

- Govind April 24, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void reverse(node * & start){

if(start==NULL) return;
node *ptr1,*ptr2;
ptr1=start->next;
start->next=NULL;
while(ptr1){
ptr2=ptr1->next;
ptr1->next=ptr1->prev;
ptr1->prev=NULL;
ptr1->next->prev=ptr1;
start=ptr1;
ptr1=ptr2;
}

}

- Anonymous June 26, 2012 | Flag Reply
Comment hidden because of low score. Click to expand.
0
of 0 vote

void reverse(node * & start){
	
	if(start==NULL) return;
	node *ptr1,*ptr2;
	ptr1=start->next;
	start->next=NULL;
	while(ptr1){
		ptr2=ptr1->next;
		ptr1->next=ptr1->prev;
		ptr1->prev=NULL;
		ptr1->next->prev=ptr1;
		start=ptr1;
		ptr1=ptr2;
	}

}

- Anonymous June 26, 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