Question 5 of 1410 points

Question 5 · 10 points

Implement a linked-list palindrome check

Implement a C function that returns non-zero when the node values read the same forwards and backwards, and 0 otherwise.

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

int is_palindrome(node_t *head);

Aim for O(n) time and O(1) auxiliary space. Explain the main steps of your algorithm. State whether your implementation restores the list before returning.

Your response

Your answer

0 words