Pergunta de entrevista da empresa Google

void fun1(struct node* head) { if(head == NULL) return; fun1(head->next); printf("%d ", head->data); }

Respostas da entrevista

Sigiloso

3 de mar. de 2016

fun1() prints the given Linked List in reverse manner. For Linked List 1->2->3->4->5, fun1() prints 5->4->3->2->1.

7

Sigiloso

6 de mar. de 2016

This method will give Null pointer exception. When head=Null then only method returns and execution pointer will come on the line printf("%d ", head->data); But, at this point head=Null so, code is trying to print null->data which will throw exception. If the 'if' condition is if(head->next == NULL) return; then linked list will be printed in reverse manner.

2