Information

Author(s) Jean-Luc Bibaud Anthony Doeraene
Deadline No deadline
Submission limit No limitation

Tags

Sign in

Reverse

In this exercice you are asked to implement a function to reverse a given linked list. So for example if your input is a list in the form a->b->c, your output should be c->b->a. You can implement this with recursion if you so desire.

You have a linked list composed of nodes.

typedef struct node{
    int val;
    struct node *next;
} node_t;

Question 1: Reverse
/*
* Reverses linked list
*
* pre         : head will not be null
*
* @return     : the head of the list reversed
*               NULL if a malloc fails
*/
node_t* reverse(node_t* head){
Question 2: Auxiliary functions

Write here your auxiliary functions