Informations

Auteur(s) Corentin Deruyck Anthony Doeraene
Date limite Pas de date limite
Limite de soumission Pas de limite

Etiquettes

Se connecter

List Equivalence

Write a function called is_equivalent which will check if two circular linked list are equivalents (containing the same values) As circular linked list doesn't have a start nor an end, the function will take as parameter a node of the linked list.

To represent a circular linked list, use the following structure:

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

An exemple of a circular linked list is given below:

https://inginious.org/admin/uclouvain-lepl1503/edit/task/list_isEqual/files?action=download&path=/student/image.png

And here's an exemple of use of the function:

noeud first (pointer to node containg 1) : 1->3->4->5->first node (1)
noeud second (pointer to node containg 5) : 5->1->3->4->first node (5)

is_equivalent(first, second, 4) returns 1 (They are the same linked list)

Is equivalent
/*
* Check if two circular linked lists are equivalent
*
* @first: a pointer to one of the node of a circular list of size "size"
* @second: a pointer to one of the node of another circular list of size "size"
* @size: the size of circular lists
*
* @return: 1 if they are equivalent, 0 otherwise
*
*/
int is_equivalent(node_t* first, node_t* second, int size){