Question: 1. What does the following function do for a given Linked Listst with first node as head? void fun1(struct node* head) { if(head == NULL)
1. What does the following function do for a given Linked Listst with first node as head?
void fun1(struct node* head) { if(head == NULL) return;
fun1(head->next);
printf("%d ", head->data); } a. Prints all nodes of linked lists.
b. Prints all nodes of linked list in reverse order.
c. Prints alternate nodes of Linked Lists.
d. Prints alternate nodes in reverse order.
2. In the worst case, the number of comparisons needed to search a singly linked list of length n for a given element is:
a. log2n. b. n/2. c. log2n-1. d. n
3. Point out the error in the following C code?
struct emp {
int ecode;
struct emp e; };
4. What does the following fragment of code do with a linked list?
current = head; while (current != null) { current = current.next; }
a) It initializes the list b) It counts the number of items in the list c) Ittraversesthelist d) None of them
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
