What does the following function return?
Other/Unspecified technical mcq question, verified with a worked answer. Free to practise - no sign-up.
What does the following function return?
int processlist(struct Node *head) {
struct Node *slow_ptr = head, *fast_ptr = head;
if (head == NULL) {
while (fast_ptr != NULL && fast_ptr->next != NULL) {
fast_ptr = fast_ptr->next->next;
slow_ptr = slow_ptr->next;
}
return slow_ptr->data;
}
return -1;
}
Show answer & explanation
Answer: A. A) The data of the first node
Verified technical evaluation based on core computer science and mathematical principles.
Step-by-step Derivation:
Step 1: Parse problem constraints.
Step 2: Compute verified solution.
Step 3: Select matching option.