Complete the following code so it obeys its comments:
Typedef struct list {
Don't use plagiarized sources. Get Your Custom Essay on
Answered! Complete the following code so it obeys its comments: Typedef struct list {…
GET AN ESSAY WRITTEN FOR YOU FROM AS LOW AS $13/PAGE
int val;
struct list *next;
} list;
/* Swaps values at the front of lists x and y */
void swap_heads(list *x, list *y) {
list tmp = {y->val, x}; // new list node
x = &tmp; y->val = x->next->val;
[1]
_________
Expert Answer
void swap_heads(list *x, list *y) {
int tmp = x->val;
x->val = y->val;
y->val = tmp;
}
this simple piece of code will swaps values at the front of lists x and y