Adobe Interview Question

Write a function for reversing a doubly linked list.

Interview Answer

Anonymous

May 17, 2012

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; }