


Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
This file contains c++ code for Insertion in linked list
Typology: Exercises
1 / 4
This page cannot be seen from the preview
Don't miss anything!



#include
tmp->next = NULL; if(head == NULL) { head = tmp; tail = tmp; } else { tail->next = tmp; tail = tail->next; } } node* gethead() { return head; } static void display(node *head) { if(head == NULL) { cout << "NULL" << endl; }
linked_list a; a.add_node(1); a.add_node(2); linked_list b; b.add_node(3); b.add_node(4); linked_list::concatenate(a.gethead(),b.gethead()); a.after(a.gethead()->next, 10); linked_list::display(a.gethead()); return 0; }