Linked List – Implementation in C/C++


See complete series on linked list here:

In this lesson, we will see implementation of basic insertion and traversal of a linked list.

Lesson on Dynamic memory allocation (malloc, new etc) –

Series on pointers in C/C++:

Drop your questions/queries in comments section.

mycodeschool on facebook :



  1. i have seen many coding videos on YouTube.
    but this channel has always provided me with the best explanations so far.
    thanks a lot for all your amazing videos.

  2. Why do we need pointer for creating nodes?why cant with normal variables?
    Like Node temp; instead of Node* temp

  3. Thanks a lot for this amazing work i was about to break down over linked lists and then you showed up man you are a life saver … i have aquestion though at the end when i want to print my elements all i get is a 4 do i tried writing printf in every loop but i still get the same result can you kindly calrify this particular problem how do i print all elements after i've traversed through the list

    thanks alot in advance and keep up the amazing work

  4. I still remember when I studied data structure in C. Sadly it is now knowledge of the past. No one in the world looks for C or data structure related skills anymore.

  5. its actually very easy but only when its taught by a good teacher! Thank you so much, was very easy to unterstand!

  6. So when you want to insert a new element into the linked list, you want temp->link to point to the address of the next cell, right? It won't be NULL anymore, but how do you write that you want to point to the next cell?

  7. Has anyone ever really tried it using C++??? cus the thing is this linked-list is not really linked!!!!! I agree that you explain the linked list in a nice way but the implementation cannot work

  8. If you wanted to make a new node, and your node* temp was still pointing to the last node, couldn't you just do:

    *(temp).next = new Node();

    To add a node to the end?

  9. Thankyou so much for your hard work .. Really learnt a lot from your videos ..I wish I could have teachers like you in my college ..

  10. Inside the while loop at 11:17 shouldn't the condition just be temp1 != NULL. temp1->link points to the link that the next node stores. So if the linked list contains only the head and one node temp1->link is NULL because it is the last node and it will not go inside the while loop. So if we want to print the values inside the while loop it won't print anything in this case. Can anyone explain to me?

  11. i have a bit of doubt: Can't we just use the A directly to store the address of new node.

    struct node
    int data;
    node *link;

    node * A;
    A=(node *) malloc(sizeof(node));
    (*A).data = 2;
    (*A).link = NULL;

  12. you are doing a = temp every time we create a node so a->next will always be NULL so How are you maintaining the header address?

  13. I guess we can add a new node to the linked list in a much better way if we keep a track of the last node ( I call it the tail ) Instead of iterating from head to tail each time .

  14. You are assigning data value to the head node and keeping the head node in the video as a node just to mention the starting point of the linked list!

  15. In python it's just two lines of code 🙂
    llist = []
    for i in range(int(input('enter count: '))):
    llist.insert(0, int(input('val: ')))



Please enter your comment!
Please enter your name here