Question
31. What is the output of the following code segment? typedef struct node{ struct node *next; int data; } Node; void foo(struct node* head) {
31. What is the output of the following code segment? typedef struct node{ struct node *next; int data; } Node; void foo(struct node* head) { if(head == NULL) return; printf("%d ", head->data); foo(head->next); } What is the output of the function foo(H), where H is the head of the following a linked list H->1->2->3->4->5->NULL 32. Write an iterative code that searches for a given record in a linked list (namely, using a for loop or a while loop). The function accepts as input the head of the list and the number to be searched and returns the last node that contains the number pg. 10 typedef struct node{ struct node *next; int data; } Node; For example if the lined list is and the function is called with H and 3 then the function will return the node that is highlighted H->1->2->3->4->5->3->5->5->NULL 33. Write a recursive code that searches for a given record in a linked list. The function accepts as input the head of the list and the number to be searched and returns the first node that contains the number typedef struct node{ struct node *next; int data; } Node; For example if the lined list is and the function is called with H and 3 then the function will return the node that is highlighted H->1->2->3->4->5->3->5->5->NULL
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started