Swap nodes in a singly-linked list

Why Infinite loop? Infinite loop is because of self loop in your list after calling swap() function. In swap() code following statement is buggy. (*b)->next = (temp1)->next; Why?: Because after the assignment statement in swap() function temp1‘s next starts pointing to b node. And node[b]‘s next point to itself in a loop. And the self … Read more

Debugging a linked-list

I’ve debugged this for you. Fixes: In list_insertn, replace the entire if statement after the “If we exceed list length append at the end” comment with: if(list == NULL){ return list_insert_tail(list, input); } In list_remove, replace the test after the “We check to see if they have the same data” comment with: if(strcmp(list->data, input) == … Read more