How to Create a Linked List C++ Introduction to Linked Lists

Share
Embed
  • Published on Dec 12, 2012
  • This tutorial provides clear visual representation of what is happening as a linked list is coded.
    Want to learn C++? I highly recommend this book amzn.to/1PftaSt
    Donate bit.ly/17vCDFx
    STILL NEED MORE HELP?
    Connect one-on-one with a Programming Tutor. Click the link below:
    trk.justanswer.com/aff_c?offer_id=2&aff_id=8012&url_id=238

    :)

Comments • 635

  • Ganesh Murmu
    Ganesh Murmu 12 hours ago +1

    Best video on universe

  • Cresence Mnyanga
    Cresence Mnyanga 4 days ago

    There is error 'n' does not name a type

  • Cresence Mnyanga
    Cresence Mnyanga 4 days ago

    Thank you so much mr.iunderstand very well

  • Matt M
    Matt M 10 days ago

    Thank you so much for doing this. This variable pointers following each node is hard to explain and understand but you did a great job. I really wish arrays in C++ were such as in PHP where they were dynamic and you and have key value pairs and values that can be different data types..

  • Zaryab Ahmed
    Zaryab Ahmed 25 days ago

    Thank u,sir! You,ve explained it so good. I was trying to get this concept for atleast 3 hours but you,ve just explained it properly in just 12 mins

  • Adde Defreitas
    Adde Defreitas Month ago

    Thanks bro

  • cppNoob
    cppNoob Month ago

    hello everyone im starting my own linked list tutorial series and would appreciate anyone stopping by to check it out thank you thexvid.com/video/QBIsnFKh44k/video.html

  • RobertO
    RobertO Month ago

    The compiler reads and assigns data from left to right, you explained the process vice versa, also, why have two variables declared as n? you unassigned one and kept the other while still using the unassigned variable

  • Craig Coleman
    Craig Coleman Month ago

    Now to get things to compile?
    How is n declared in the main()?
    Nice video!
    // cwc pointers.cpp
    // reference thexvid.com/video/o5wJkJJpKtM/video.html
    // thexvid.com/channel/UCcDGsN3JxMavDkM9INRLGFA
    #include
    using namespace std;
    struct node{
    int data;
    node* next;
    };
    int main(){
    int t,h;
    n = new node;
    n->data = 1;
    t = n;
    h = n;
    n = new node;
    n->date = 2;
    t->next = n;
    t=t->next;
    n = new node;
    n->date = 3;
    t->next = n;
    n = new node;
    t=t->next;
    n->date = 4;
    t->next = n;
    n->next = NULL;
    return 0;
    }

  • XenomorphLV426
    XenomorphLV426 2 months ago

    Excelente

  • atsam ali
    atsam ali 2 months ago

    Thanks Alot

  • Sens Edits
    Sens Edits 2 months ago

    Thank you sincerely!!!

  • M.Talha Arshad
    M.Talha Arshad 2 months ago

    Beautiful explanation!

  • preity chib
    preity chib 3 months ago

    Thank u next 😅
    Just kidding, really it helped me alot sir .

  • shubhankar jadhav
    shubhankar jadhav 3 months ago

    thanks a lot bro

  • Mini Zacharias
    Mini Zacharias 3 months ago +2

    Wow.. You made it seem simple.. Luv from India
    2019 anyone??

  • انا مسلم و كفى

    whts the convert * in c#???

  • Thuyên Hà
    Thuyên Hà 3 months ago

    Thank sir. From VietNam

  • teemo captain1997
    teemo captain1997 3 months ago

    thanks you m8
    you help me alot

  • Joey Sheridan
    Joey Sheridan 3 months ago

    Great video! Thank you so much for the content

  • WesamConTECH
    WesamConTECH 3 months ago

    Great video I really appreciate the sequence you worked with.
    I've got a question though.. Is it possible to create a loop that generates this list until for example reaches number 5 of data? then the last node will point to NULL? Cause I want to shorten my code

  • Songsuk Dumrongwibulsin

    Thank you so much! YOU ARE THE BEST!!! Now I know what linked list is after scratching my head for so many days.

  • Gabriel Murillo
    Gabriel Murillo 3 months ago

    CS106B gang

  • Abdul Mueez
    Abdul Mueez 3 months ago

    this kind of basic code is perfect to understand link list thanks.

  • Hà Quang
    Hà Quang 3 months ago

    temporary for what? Actually don't understand

  • Mariam Albarghouti
    Mariam Albarghouti 4 months ago

    Thank you

  • Rodrix183
    Rodrix183 4 months ago

    Useful for my exams

  • yash chauhan
    yash chauhan 4 months ago

    Simply awesome, best explanation. Thumbs up for that

  • SharadRawat
    SharadRawat 4 months ago

    Great explanation! Thanks for being concise!

  • Savan Panchal
    Savan Panchal 4 months ago

    Explained Too Good!!!! Making Life Easy!!!!

  • Rahul Mundefi
    Rahul Mundefi 4 months ago

    finally understood it thanks

  • Taylor B
    Taylor B 4 months ago

    Your smoke detector is running low on battery, thanks for the wonderful explanation!

  • Ganesh Rajan
    Ganesh Rajan 4 months ago

    I LOVE YOU SO MUCH THANK YOU

  • ZombianGaming
    ZombianGaming 5 months ago

    yes perfectly n that helps bro

  • DODDY LINO SAKMAD -
    DODDY LINO SAKMAD - 6 months ago

    YOURE A GENIUS

  • Kaleem Ullah
    Kaleem Ullah 6 months ago

    Subscribed for this video

  • Salvatore Granata
    Salvatore Granata 6 months ago

    I've understand in 12 minutes everything you said speaking in english but nothing of 2 hours lesson of my Italian teacher.... LOVE YOU.
    A question: What happens if I write struct node n=NULL?
    I've noticed it is so important in my all programs but what does physically happen? In the n block you write NULL?

  • hotmandead1
    hotmandead1 6 months ago

    Great explanation

  • Sanjay Tumati
    Sanjay Tumati 6 months ago

    Hi Paul, You've assigned n= new node twice. It appears that when you assign n->data = 2, it will just rewrite the original location when you had written 1 to 2. You might need to create a new memory location, I think. Do let me know where I am going wrong.

  • MAXIMUM MAOKAI
    MAXIMUM MAOKAI 6 months ago

    Thank you very much. That is so helpful.

  • Florentin Niyongere
    Florentin Niyongere 6 months ago

    Awesome!

  • Kaushal Makwana
    Kaushal Makwana 6 months ago

    Wonderfully explained

  • Emmanuel Lazarte
    Emmanuel Lazarte 6 months ago

    This video is amazing. I'd like to watch a video like this about double linked list, is it possible that you can do it ? Thanks a lot

  • Emmanuel Lazarte
    Emmanuel Lazarte 6 months ago

    Nice, ty!

  • Walker Bass
    Walker Bass 6 months ago

    ily Paul

  • dougsjk
    dougsjk 6 months ago

    great explanation!

  • Sumit Kumar
    Sumit Kumar 6 months ago +3

    I wish I could like it zillion times.

  • Joiney Nguyen
    Joiney Nguyen 6 months ago

    Thank you thank you thank you!

  • blessed
    blessed 6 months ago

    so basically im monky

  • Tim Drake
    Tim Drake 7 months ago

    Thanks bruh ....You just saved my ass big time

  • Lauro Castro Gonçalves

    Thank you very much. You taught me so much in these 12 minutes my teacher couldn't teach me in 8 hours.

  • Brian Salkas
    Brian Salkas 7 months ago

    11:54 change the batteries in your smoke detector.

  • Asad Ullah Shaban
    Asad Ullah Shaban 7 months ago

    Please Can you explain code of linkedlist functions like function of insertatstart() , insertatend() , deleteatstart() and deleteatend() ,, i have the code but unable to understand how they work and make changes in linkedlist,,,, these functions are created in class ... I'm sharing code in reply of this comment.

    • Asad Ullah Shaban
      Asad Ullah Shaban 7 months ago

      This code is in C++.

    • Asad Ullah Shaban
      Asad Ullah Shaban 7 months ago

      You can run this code!!!

    • Asad Ullah Shaban
      Asad Ullah Shaban 7 months ago

      #include
      using namespace std;
      struct Node
      {
      int data;
      Node*next;
      };

      class linkedlist
      {
      private:

      Node*head;

      public:

      linkedlist() // Constructor
      {
      head=NULL;
      }

      void traverse() // Function to show data in linkedlist
      {
      Node*temp=head;
      while (temp!=NULL)
      {
      cout next;
      }

      }

      void insertatstart(int num ) // function to add data at the start of linkedlist
      {
      Node*First=new Node;
      First -> data = num ;
      First -> next=head;
      head=First;

      }

      void insertatend(int num ) // function to add data at the end of linkedlist
      {
      // trying to write!!!!!
      }

      void deleteatstart() // function to delete data at the start of linkedlist
      {
      Node*temp=new Node;
      temp=head;
      head=head -> next;
      delete temp;
      }

      void deleteatend() // function to delete data at the end of linkedlist
      {
      Node*previous=new Node;
      Node*current=new Node;
      current = head;


      while(current -> next !=NULL)
      {
      previous=current;

      current = current -> next;
      }
      previous -> next =NULL;

      delete current;
      }

      };


      int main()
      {
      linkedlist l;
      l.insertatstart(1);
      l.insertatstart(2);
      l.insertatstart(3);
      l.insertatstart(4);
      l.insertatstart(5);

      l.traverse();
      cout

  • Ramish Masood
    Ramish Masood 7 months ago

    Wonderful. Thank you!

  • RAMYASRI DUBHAKULA
    RAMYASRI DUBHAKULA 7 months ago

    tq sir

  • TJ Khara
    TJ Khara 7 months ago

    Excellent video. Thank you!

  • John Michael San Diego
    John Michael San Diego 7 months ago

    Thank you sir, Well explained!

  • Abby Aguilar
    Abby Aguilar 7 months ago

    Finally a voice I understand...

  • REHAB.
    REHAB. 8 months ago

    Thnx man $:

  • Kelvin Ojiako
    Kelvin Ojiako 8 months ago +1

    Very useful

  • ashwin kumar
    ashwin kumar 8 months ago

    hey paul , how'll traverse the list to print all these elements ?

  • Emmanuel Gatica
    Emmanuel Gatica 8 months ago

    This was amazing!!!! I am so glad I found this video. I wouldn't mind paying you thousands of dollars in tuition since you actually taught me something unlike my teachers.

  • Xi Gong
    Xi Gong 8 months ago

    Great video! Thanks.

  • Hamza Bodla
    Hamza Bodla 8 months ago

    life saver!!

  • OV
    OV 8 months ago

    Great Explained ... Thank You .. Keep up The good work ... :)

  • Dr. Omkar Bhandari
    Dr. Omkar Bhandari 8 months ago

    great.love from india.......

  • salpls !
    salpls ! 8 months ago

    This really summarize everything that I needed to understandfor my midterm. Thank you so much for making the time to do this video.

  • LaliGirl
    LaliGirl 8 months ago

    Thoroughly grateful for this video!

  • Ali
    Ali 8 months ago

    Did anyone else try wiping that smiley line off their monitor?

  • veselka slavceva
    veselka slavceva 8 months ago

    Perfect exlanation! Admirations!

  • DHRUVIL PUJARA
    DHRUVIL PUJARA 8 months ago

    How to move the last node of a linked list to the middle of the list:
    Do check this out - thexvid.com/video/tsRqKCqUdIY/video.html

  • Almost Dead
    Almost Dead 8 months ago

    THANK YOU

  • Jairo Acosta
    Jairo Acosta 8 months ago

    Thank you

  • Gloria Ballard
    Gloria Ballard 9 months ago

    Awesome video easy to follow along

  • Vijaykumar Badhe
    Vijaykumar Badhe 9 months ago

    Thank you ,sir

  • kev814445
    kev814445 9 months ago

    Extremely helpful! Thank you

  • AdiTya Dev
    AdiTya Dev 9 months ago

    Awesome

  • Fatim IVORY
    Fatim IVORY 9 months ago

    I literally learned in 14 min what my professor spent 2 weeks explaining. Thank you !

  • Fissle Wine
    Fissle Wine 9 months ago

    Why use t and h? As you can create all nodes and sets it node to a node, also it could have been easier to used a node pointer class.

  • Juy San
    Juy San 9 months ago

    very clear now

  • Marcella Ingrid Moura Freitas

    Perfect explanation! I love you

  • munde bt
    munde bt 10 months ago

    U R great man!!!!!!!

  • Brandon Baugh
    Brandon Baugh 10 months ago

    Have spent the last year trying to understand this from two different professor and it took you all of 12 minutes. Thank you for the simplicity and brevity!

  • Mutualist ball
    Mutualist ball 10 months ago

    After watching this video twice I finally got the idea,thank you 🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻🙏🏻

  • Athira Prasannakumar
    Athira Prasannakumar 10 months ago

    beautifully explained...!!...tnx.

  • anyno k
    anyno k 10 months ago

    Thanks max.It's really help to understand the concept

  • Jigar Patel
    Jigar Patel 10 months ago

    can you please make more videos on specifically: queues, graphs & graph traversals, tries, sorting algorithms(merge sort, quick sort, insert sort, heap sort, etc), and big-o notation?

  • Rohan Kar
    Rohan Kar 10 months ago

    Your twelve mins explanation helped me with my 12 hours of struggle

  • HUSTLE MEDIA
    HUSTLE MEDIA 10 months ago

    very good explanation bro. I can't understand this concept when in class your video helped me so much

  • Fady A.Malak
    Fady A.Malak 10 months ago

    good video ,,
    i was hopping to make it more dynamic by using loops

  • Ichmood
    Ichmood 11 months ago

    my lect made this difficult lel

  • Arsalan wasim
    Arsalan wasim 11 months ago

    miraculous

  • R T
    R T Year ago

    You just earned yourself a subscriber. I was NOT getting the fact that 'n' was a pointer and when you loop again to create more values in the list you were moving the 'n' pointer and not the actual values around in the list. Great video and great explanation. Keep up the great work.

  • Flaze07
    Flaze07 Year ago

    Why struct

  • Tural Ahmadov
    Tural Ahmadov Year ago

    Thank you. Really helped 👍

  • Kyle Corcoran
    Kyle Corcoran Year ago

    When you originally assign [t = n;] and [h = n;], how come they don't point to the new node when you re-assign n = new node? (from node --> data =1 to node--> data=2)

  • Lengdon Baruah
    Lengdon Baruah Year ago

    One of the most detailed video... Thank you

  • Yit Wei Chia
    Yit Wei Chia Year ago

    crystal clear, thank you !

  • Dika Rv
    Dika Rv Year ago

    I understand what you describe, this is very helpful to me thank u man ^-^

  • kalana de silva
    kalana de silva Year ago

    wow you made it super easy to understand. Are you looking for a instructor position in college ? LOL