Question
Please explain graphically how the values interact with each other: 2) Suppose we have a singly linked list implemented with the structure below and a
Please explain graphically how the values interact with each other:
2) Suppose we have a singly linked list implemented with the structure below and a function that takes in the head of the list. typedef struct node { int num; struct node* next; } node; int whatDoesItDo (node * head) { struct node * current = head; struct node * other, *temp; if (current == NULL) return head; other = current->next; if (other == NULL) return head; other = other->next; temp = current->next; current->next = other->next;
current = other->next; if (current == NULL) { head->next = temp; return head; } other->next = current->next; current->next = temp; return head; } If we call whatDoesItDo(head) on the following list, show the list after the function has finished. head -> 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7
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