Pergunta de entrevista da empresa NVIDIA

Q: Print a LL in reversed order. 1) recursive 2) non recursive

Resposta da entrevista

Sigiloso

12 de ago. de 2015

void ReverseListRecursive(Node *head) { if(head != NULL) { ReverseList(head->next); printf(" %d \n", head->data); } return; } void reverse_non_recursive(Node **head){ if (!head) return; Node *prev=NULL; Node *cur = head; while(cur) { Node *next = cur->next; cur->bext= prev; prev=cur; cur=next; } head=prev; }