Questions about Linked Lists?

swap in linked list

swap in linked list

par amir el halabi,
Nombre de réponses : 2
Avatar GroupEn
typedef struct node{
    int data;
    struct node* next;
}node;
swapInList()  :  in this case we only have data in the node , can we swap data(in the exam)? as in the exercice on moodle lab on linked list of integers  (u already asked to swap elements if possible but in the exam can we do that if we have one element? swap data instead of nodes?)
 
i know that this only differs if there is other elements in the struct (more than 1 which is data here) that's why i'm asking in case in the exam u asked swap function
En réponse à amir el halabi

Re: swap in linked list

par Siba Haidar,
In case of the exam. If swapping data themselves is not allowed, usually it is clearly mentioned. Review the previous questions. We write something like: you are not allowed to swap the data inside the nodes, as the nodes may by referenced by other pointers and this may lead to confusion / errors.