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

Range of linked lists [closed]

Your linked list declaration is wrong. You don’t use [] when creating a new object in java. Instead you use (). And your generic type is also wrong -> if you want to have more linked lists inside the main linked list. Try this LinkedList<LinkedList> LK = new LinkedList<>(); Note – The part inside <> … Read more

Assorting linked list in c [duplicate]

Simplest will be bubble sort. item* sort(item *start){ item *node1,*node2; int temp; for(node1 = start; node1!=NULL;node1=node1->next){ for(node2 = start; node2!=NULL;node2=node2->next){ if(node2->draw_number > node1->draw_number){ temp = node1->draw_number; node1->draw_number = node2->draw_number; node2->draw_number = temp; } } } return start; }

CPP- I am getting Segmentation fault (core dumped)?

That’s why there are debug tools like gdb (just google for it 😉 ). This is the backtrace: #0 0x00000000004009ba in node::setnext (this=0x0, x=0x614cc0) at a.cpp:25 #1 0x0000000000400c18 in list::insertend (this=0x7fffffffdf10, x=45) at a.cpp:109 #2 0x00000000004008df in main () at a.cpp:137 that means in line 137 there is a function call (l.insertend(45)), then in line … Read more