What does the following function do for a given Linked List with first node as head?
void fun1(struct node* head)
{
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
void fun1(struct node* head) {
if(head == NULL)
return;
fun1(head->next);
printf("%d ", head->data);
}
void fun1(Node head) {
if(head == null)
return;
fun1(head.next);
System.out.print(head.data + " ");
}
def fun1(head):
if head is None:
return
fun1(head.next)
print(head.data, end=' ')
function fun1(head) {
if (head === null)
return;
fun1(head.next);
console.log(head.data + ' ');
}
Prints all nodes of linked lists
Prints all nodes of linked list in reverse order
Prints alternate nodes of Linked List
Prints alternate nodes in reverse order
This question is part of this quiz :
Top MCQs on Linked List Data Structure with Answers