Doubly Linked List - Implementation in C/C++

แชร์
ฝัง
  • เผยแพร่เมื่อ 28 พ.ย. 2024

ความคิดเห็น • 281

  • @kunal1035
    @kunal1035 3 ปีที่แล้ว +35

    8 years passed by and this channel is still helping thousands!!

  • @nguaial8490
    @nguaial8490 8 ปีที่แล้ว +53

    I just want to mention that I really appreciate you repeating the important concept over and over again.
    I don't know about the others, but I really have hard time grasping the memory structure concept inside a computer since I haven't seen one. The only way I get it is when I look and listen the subject repetitiously.

  • @kevincaasi926
    @kevincaasi926 7 ปีที่แล้ว +81

    This is beautiful. Thank you for taking your time and effort in explaining how to implement doubly linked lists as well as their actions on the different memory locations. You possess great pronunciation, clarity, knowledge, and appropriate talking speed. Thank you!

  • @pranavofindia
    @pranavofindia 6 ปีที่แล้ว +255

    lets watch the complete ads without skipping and appreciate this man.

    • @navkaransingh3948
      @navkaransingh3948 6 ปีที่แล้ว

      @ how ?

    •  6 ปีที่แล้ว

      He died in a hit and run. Someone hit him with his/her car and ran and drove off.

    • @lasyagajavelli594
      @lasyagajavelli594 6 ปีที่แล้ว

      really..?

    • @standardgu3773
      @standardgu3773 6 ปีที่แล้ว

      @@lasyagajavelli594 I want to know the truth....

    • @lasyagajavelli594
      @lasyagajavelli594 6 ปีที่แล้ว +1

      @@standardgu3773 I don't knw either...wherever he is he has to be happy

  • @mymanhapt
    @mymanhapt 8 ปีที่แล้ว +17

    It's the best "data structures" tutorial list I've seen in the planet !

  • @kanishkjain2767
    @kanishkjain2767 6 ปีที่แล้ว +24

    wow sir
    finally i understand why we are using dynamic memory allocation instead of normal allocation
    i know you cant read any of our comments but still i want to say that u will always be the best teacher not only for me but for most of the online community who are still watching and learning from your videos

  • @antor.morsalin
    @antor.morsalin ปีที่แล้ว +3

    There is an easier way to print a list in reverse. We can always store the address of the last Node in the variable Node* tail. Tail will change depending on which Node is at the last position each time we add a New node in the list. We can start at the Tails and using the previous address we can print the list in reverse order, This way we won't have to iterate the entire list before printing it in reverse. I also want to say this is a great video series. The clarity I got on this topic just after watching it once is insane.

  • @TheHyperActiveRedditBot
    @TheHyperActiveRedditBot 2 ปีที่แล้ว +4

    Your way of communicating an idea is near perfect (unlike most other coding youtube channels). Keep up the good work.

    • @knanzeynalov7133
      @knanzeynalov7133 ปีที่แล้ว

      @@mahedihassanshawon4821 are you serious????/

  • @bhavanababua959
    @bhavanababua959 3 ปีที่แล้ว +1

    I cleared my technical interview after watching these video. Thanks for uploading these clear and precisely explained videos.

  • @zeeshanayub9706
    @zeeshanayub9706 7 ปีที่แล้ว +8

    Sir, I can't even express how helpful your tutorials are to me. Thank you so much for making them!!

  • @justdanaus
    @justdanaus 4 ปีที่แล้ว +3

    I don't know why my professor can't not explain this easy as you do! I really hate pointer until I found your great video. You got new subscriber!

  • @maliksaraanasim5404
    @maliksaraanasim5404 5 ปีที่แล้ว +1

    Yaar bhai tum saviour ho,I can not thank you enough .Seriously.

  • @毛喬-o6t
    @毛喬-o6t ปีที่แล้ว +1

    this is the best DS video i have ever seen

  • @scotfsh5014
    @scotfsh5014 2 ปีที่แล้ว +2

    Thank you so much humblefool, you make the world a better place.

  • @firkyunbanaya
    @firkyunbanaya 8 ปีที่แล้ว +1

    Watching this video lectures should be made a part of the College curriculum.These videos helped me a lot during preparations for Exams.

  • @Facttoknowabout
    @Facttoknowabout 7 หลายเดือนก่อน

    10 years passed but this channel is helping students now also .

  • @shobhitrealm
    @shobhitrealm 5 ปีที่แล้ว +1

    RIP man, even though you are no more your videos are still helping us all.

    • @KeshavUjoodha
      @KeshavUjoodha 4 ปีที่แล้ว +1

      He isn't dead. His name is Animesh Nayan
      . His friend Harsha Suryanarayana is the co-founder to this channel and he is no more. He died in a car accident 15th June 2014. Animesh Nayan
      is a Software Engineer at Google.
      "Harsha was the best coder India has ever produced. He was working in a start-up (that he co-founded with Animesh Nayan) MyCodeSchool. He was alumni of Indian Institute of Information Technology, Allahabad. We lost him in a hit and run accident on the night of 15th June 2014."
      [Source: fossiiita.github.io/humblefoolcup/humblefool/humblefool.html]

  • @anusrees3991
    @anusrees3991 7 ปีที่แล้ว

    this is the frst tutorial in which i see things explained via code, graphical representation and memory allocation process

  • @AlphaZubair
    @AlphaZubair 8 หลายเดือนก่อน

    10 years passed by and these explaination of concepts are Just like a WoW...

  • @monicaslv323
    @monicaslv323 9 ปีที่แล้ว +24

    Thank you for every codeline of yours.

  • @raduchirilov4800
    @raduchirilov4800 4 ปีที่แล้ว +1

    This is the very definition of a "clear code"
    Thank you so much!

  • @hassan4834
    @hassan4834 8 ปีที่แล้ว +1

    You have done a great Job ! You really made things easier to understand.. Lectures like this are very hard to find on internet hats off :)

  • @thestarinthesky_
    @thestarinthesky_ 4 ปีที่แล้ว +5

    @3:13 BLOWS MY MIND! Impressive! Thank you.

  • @pcpardon
    @pcpardon 3 ปีที่แล้ว +1

    Impeccable explanation!!! Cleared all the doubts what I had. I have no words to say thanks..

  • @TheFlexath
    @TheFlexath 8 หลายเดือนก่อน

    the best data structures playlist ever!

  • @meghamalviya8495
    @meghamalviya8495 5 ปีที่แล้ว

    BEST Tutorials of DS...excellent explanation...supreme clarity and knowledge

  • @anandsatija6172
    @anandsatija6172 8 ปีที่แล้ว +27

    guru dronacharya of data structure :)

  • @mohitsrvv
    @mohitsrvv 3 ปีที่แล้ว

    many years but still watching thanks

  • @antragupta1001
    @antragupta1001 7 ปีที่แล้ว

    sir always u say thanks for watching ..today I m saying thanks for making ......I can't tell u how relieve I m feeling after watching this ..... cz tomorrow is my exam ...
    😍😍😍

  • @aryannijhawan8448
    @aryannijhawan8448 4 ปีที่แล้ว +3

    u said u were gonna talk about circularly linked list . This is really an amazing playlist I wish this was more comprehensive. Thanksss :)))

  • @asmereg
    @asmereg 4 ปีที่แล้ว

    Such a great teacher! Please come back

  • @danielabonvini2936
    @danielabonvini2936 7 ปีที่แล้ว +2

    Thank you, finally getting to understand how DLL work

  • @kuonkhailechdawech2309
    @kuonkhailechdawech2309 ปีที่แล้ว +1

    You're legend brother 🙏

  • @lucafrazz6199
    @lucafrazz6199 8 ปีที่แล้ว +2

    Very awesome! I don't speak english very well but i have understood all... this is a very nice tutorial.

  • @mashable8759
    @mashable8759 8 ปีที่แล้ว +57

    All the tutorials are the best and really helpful :D
    MAY ALLAH GUIDE YOU

    • @shobhitrealm
      @shobhitrealm 5 ปีที่แล้ว

      He is no more. He died on 15th June 2014.

    • @muktamalakar5771
      @muktamalakar5771 5 ปีที่แล้ว +3

      Fuck off dude, if you want to believe in 7th century bullshit, don't use technology and watch these videos.

  • @abhirupbasak5035
    @abhirupbasak5035 4 ปีที่แล้ว

    you guy just amazing ..even my teacher can't explain like this

  • @ucthuanphung4530
    @ucthuanphung4530 6 ปีที่แล้ว +1

    Videos are extremely clear and useful. Thanks a lot.

  • @shikharyadav4898
    @shikharyadav4898 2 ปีที่แล้ว +1

    Assignment - Inset at tail , Deletion
    public void insertAtEnd(int data) {
    Node newN = new Node(data);
    if (head == null) {
    head = newN;
    previous = head;
    } else {
    newN.prev = previous;
    previous.ref = newN;
    previous = newN;
    }
    }
    public void delete(int pos) {
    Node current = head;
    int traversalCnt = 0;
    while (current != null) {
    ++traversalCnt;
    if (traversalCnt == pos) {
    if (current.prev == null) {
    //moving head to next node
    head = current.ref;
    //updating 2nd nodes prev to null , else it will keep referring deletd node
    current.ref.prev = current.prev;
    } else {
    //updating adjacent nodes
    current.prev.ref = current.ref;
    current.ref.prev=current.prev;
    }
    return;
    }
    current = current.ref;
    }
    }

  • @rabinrai5838
    @rabinrai5838 7 ปีที่แล้ว +12

    sir where is the video for circular linked list?????
    and thanks for ur videos helping me a lot

  • @poojagoyal869
    @poojagoyal869 7 ปีที่แล้ว +1

    One of the best tutorial...thank you sir...

  • @narapareddy8256
    @narapareddy8256 3 หลายเดือนก่อน +1

    nice explation sir . from iit bombay cse

  • @findoc9282
    @findoc9282 3 ปีที่แล้ว

    Bro thank you so much and I wish u had good life up there

  • @renelhomere5243
    @renelhomere5243 8 ปีที่แล้ว +2

    Thank you so much, you've help me get through the portion of class. 👍🏾👍🏾

  • @arpitj795
    @arpitj795 8 ปีที่แล้ว

    thank you for making things simpler.

  • @dheerajdhall8482
    @dheerajdhall8482 8 ปีที่แล้ว

    Thank you for taking out time and making these videos. I really like the way you explain these concepts. Cheers!!

  • @Maurin4000
    @Maurin4000 10 ปีที่แล้ว

    best explanation so far, thx a lot

  • @sreekumarmenon
    @sreekumarmenon 11 ปีที่แล้ว +15

    isn't it more efficient to have a tail pointer (similar to head pointer) to traverse backwards?

    • @mycodeschool
      @mycodeschool  11 ปีที่แล้ว +22

      We may or may not keep a tail pointer. Its good to keep a tail pointer, depends upon the use case. When we implement queue using doubly linked list, we keep a tail pointer. But in general, if we would have two links - forward and backward, that's what we would call a doubly linked list.

  • @adityasinghaswal4923
    @adityasinghaswal4923 8 ปีที่แล้ว +4

    +mycodeschool why don't you make videos anymore sir :|
    easily the best video tutorials i have seen :)

    • @himanshusomani7
      @himanshusomani7 6 ปีที่แล้ว

      he is dead

    • @iwayanbagus2271
      @iwayanbagus2271 6 ปีที่แล้ว +5

      Actually If am not mistaken, he is working at Google now, LOL
      btw thanks to him, he made great videos, Indian Software Engineers are the best

    • @AnkitPandey-ft8jb
      @AnkitPandey-ft8jb 6 ปีที่แล้ว +1

      Hey man! he is not joking, it really breaks my heart, such a nice person died in a hit and run case. Check out this link. He was one of the best programmers from India. RIP
      yourstory.com/2014/06/techie-tuesdays-humblefool/

  • @arukoul6364
    @arukoul6364 6 ปีที่แล้ว

    Thank you so much, your videos are really very nice for learning Data Structures. Thank you, Sir for this beautiful learning gift.

  • @akashdeep504
    @akashdeep504 9 ปีที่แล้ว +7

    please upload some lectures on dynamic programming

  • @rafay1067
    @rafay1067 3 ปีที่แล้ว

    I am watching videos today and day after tomorrow I have data structure exam.

  • @DiogoNeves
    @DiogoNeves 8 ปีที่แล้ว +3

    This is brilliant! Thanks! :)
    You don't talk about deallocating the nodes after we're done with the list. Shouldn't that be done explicitly since we allocated them in the heap?

  • @gamereplayhq
    @gamereplayhq 8 ปีที่แล้ว +2

    is this a good approach , i just included a constructor which set next and prev to NULL , so that we dont need to worry about setting up next and prev while inserting a new node ?
    struct node
    {
    node *next;
    node *prev;
    int data;
    node()
    {
    next=NULL;
    prev=NULL;
    }
    } *start=NULL,*temp,*end=NULL;
    void insert_beg(int x)
    {
    temp = new node;
    if(temp==NULL) exit(0);
    temp->data =x ;
    temp->next=start;
    if(start!=NULL)
    start->prev = temp;
    start=temp;
    if(end==NULL)
    end=start; //initially
    }
    is this a good approach ? since now we need not worry about next and prev being NULL , since they would by default be pointing to NULL ... ?

  • @46_wrtyui
    @46_wrtyui 8 ปีที่แล้ว

    Very awesome class. But please reduce the time on the difference among the memory sections since it already introduced several times in previous lessons.

  • @harshitsoora1313
    @harshitsoora1313 6 ปีที่แล้ว

    awewewewesome bro ,you have superb teaching experience ,aise hi machatte raha

  • @vijaymalawadkar6830
    @vijaymalawadkar6830 6 ปีที่แล้ว

    Thank you for easy explanation of linked list

  • @RatIceCream
    @RatIceCream 3 ปีที่แล้ว

    Thanks for uploading!

  • @shivanshbhardwaj5841
    @shivanshbhardwaj5841 4 ปีที่แล้ว +1

    Great video!!!!!!!!!!!!!!!!

  • @machinelearning3518
    @machinelearning3518 3 ปีที่แล้ว

    i'm grateful for ur video

  • @Mhmoudko
    @Mhmoudko 9 ปีที่แล้ว

    Thank you man , you're a life saver ...

  • @yogabrindha5640
    @yogabrindha5640 3 ปีที่แล้ว

    Clean explaination

  • @senku3288
    @senku3288 5 ปีที่แล้ว

    You can use typedef struct
    And then you can (node*) instead of (struct node*)

  • @wannabe.explorer
    @wannabe.explorer 8 ปีที่แล้ว

    cleared my concept..thanks sir!!

  • @vsiddharth1996
    @vsiddharth1996 4 ปีที่แล้ว +2

    #include
    using namespace std;
    struct node
    {
    int data;
    node *next;
    node *prev;
    };
    node *newnode,*head=0,*tail=0,*temp;
    node *currentnode,*nextnode;
    class linkedlist
    {
    int value;
    int position;
    int count;
    public:
    void insertelement()
    {
    coutvalue;
    newnode=new node;
    newnode->data=value;
    newnode->next=NULL;
    newnode->prev=NULL;
    if(head==0)
    {
    head=tail=newnode;
    }
    else
    {
    tail->next=newnode;
    newnode->prev=tail;
    tail=newnode;
    }
    }
    void traverse()
    {
    if(head==NULL)
    {
    coutprev=NULL;
    head->prev=newnode;
    newnode->next=head;
    head=newnode;
    }
    else
    if(position==( noofelements()+1) && head!=NULL)
    {
    newnode->data=value;
    newnode->next=NULL;
    newnode->prev=NULL;
    tail->next=newnode;
    newnode->prev=tail;
    tail=newnode;
    }
    else
    if( (position < noofelements() ) && head!=NULL)
    {
    int i=1;
    temp=head;
    while(inext;
    i++;
    }
    newnode->next=temp->next;
    newnode->prev=temp;
    temp->next=newnode;
    newnode->next->prev=newnode;
    newnode->data=value;
    }
    else
    coutprev=NULL;
    head->next=NULL;
    coutprev;
    cout

  • @daoanhtuandao8106
    @daoanhtuandao8106 8 ปีที่แล้ว

    your videos are helpful .I learned more good knowledge .

  • @095_shaniabalkhi9
    @095_shaniabalkhi9 3 ปีที่แล้ว

    Great explanation!

  • @AdityaPratapsingh9125
    @AdityaPratapsingh9125 8 ปีที่แล้ว

    Kindly make a video on important operations on doubly linked list like insertion at middle ,deleting a node from middle etc

  • @abhiseksen1817
    @abhiseksen1817 10 ปีที่แล้ว +2

    @13:37 please correct head value. it should be 600.:)

  • @bilalqadri5312
    @bilalqadri5312 2 ปีที่แล้ว

    very helpful tutorial ❤❤❤❤❤

  • @pulkit0581
    @pulkit0581 8 ปีที่แล้ว

    thanks alot. This is very helpful. Please suggest how should i proceed for preparing competitive programming after going through all the data structure series and others available on mycodeschool

  • @w4h175
    @w4h175 3 ปีที่แล้ว

    hats off sir ji..

  • @mirzaavez6284
    @mirzaavez6284 9 ปีที่แล้ว

    Thanks sir for explaining this topic

  • @anandsatija6172
    @anandsatija6172 8 ปีที่แล้ว

    sir ji u r great teacher

  • @rahuls331
    @rahuls331 6 ปีที่แล้ว

    Instead of traversing list each to perform insert to delete operating, using a node pointer to tail(last node) would be efficient.

  • @MOHDNAVEED1
    @MOHDNAVEED1 11 ปีที่แล้ว

    awesome compilation

  • @dhruvgaba865
    @dhruvgaba865 5 ปีที่แล้ว

    nice explanation

  • @ricardohincapie1537
    @ricardohincapie1537 4 ปีที่แล้ว

    Thank you very much for this video. It is really understandable!

  • @CODINC
    @CODINC 7 ปีที่แล้ว

    Absolutely Amazing man!!!

  • @drewpatton4275
    @drewpatton4275 4 ปีที่แล้ว

    You are a saint.

  • @RajahChandrasekhar
    @RajahChandrasekhar 6 ปีที่แล้ว

    Best tutorial ever!!!

  • @amateurbeginner7538
    @amateurbeginner7538 7 ปีที่แล้ว

    if head is not global variable then this code is suitable:
    struct Nodes* insertOnTail(struct Nodes *head1,int x){
    struct Nodes *newnode=NewNode(x);
    struct Nodes *head=head1;
    if(head == NULL){
    head=newnode;
    return head;
    }
    while(head->next != NULL){
    head=head->next;
    }
    newnode->prev=head;
    head->next=newnode;
    newnode->next=NULL;
    return head1;
    }

  • @Christine-ne3dw
    @Christine-ne3dw 5 ปีที่แล้ว

    Thanks, I appreciated this a lot.

  • @roopanrodin7924
    @roopanrodin7924 6 ปีที่แล้ว

    Thank so much for the lesson.
    It was very useful, thank you a lot

  • @Nino-bd7bp
    @Nino-bd7bp 7 ปีที่แล้ว +1

    OMG thank you very much!!! This really helped me :)

  • @lilianawong4819
    @lilianawong4819 5 ปีที่แล้ว +1

    When the new node was created with the address 600 was it suppose to be | 0 | 4 | 0| ?

  • @yichizhang795
    @yichizhang795 9 ปีที่แล้ว

    Good work sir, Thanks!

  • @Rizzan8
    @Rizzan8 7 ปีที่แล้ว +2

    Wouldn't the use of malloc and not using free() cause a memory leak?

  • @usama57926
    @usama57926 6 ปีที่แล้ว

    this tutorial is amazing

  • @malazalzarrad6064
    @malazalzarrad6064 4 ปีที่แล้ว

    you are the king

  • @yashkothari7540
    @yashkothari7540 8 ปีที่แล้ว +4

    Also what do you mean by :
    head -> prev = newNode;
    newNode -> next = head;
    head = newNode;
    should we not write :
    head = newNode;
    newNode -> prev = head;

    • @tomasz-rozanski
      @tomasz-rozanski 7 ปีที่แล้ว +4

      If you insert newNode at head, newNode->prev will always point to NULL because it's now first element in the list (a new head). The old head is becoming the second element of the list, that's why newNode->next must points to it and head->prev points back to newNode.
      In your example head will be equal to newNode, newNode->prev will point back to newNode itself and newNode->next is already NULL. This way every time you're inserting node at head you're really throwing away the old head node so the list will always have one element - the last one you have inserted.

  • @antoniomellobabo1229
    @antoniomellobabo1229 3 ปีที่แล้ว

    Thx helped a lot!

  • @bleep4930
    @bleep4930 8 ปีที่แล้ว

    awesome videos broh..thanx a lot..how do u writ em ? lik wat software do u use..or what device ?

  • @wareshakhan5740
    @wareshakhan5740 9 ปีที่แล้ว

    amazing you are great teacher

  • @stevejerry808
    @stevejerry808 4 ปีที่แล้ว

    really solid thank you

  • @rupaliroychoudhury2300
    @rupaliroychoudhury2300 9 ปีที่แล้ว +7

    sir, for reverse print one can do:
    void reversePrint()
    {
    temp = tail;
    if(temp == NULL)
    {
    cout prev;
    }
    cout

    • @knoxvoxx
      @knoxvoxx 7 ปีที่แล้ว

      but what is tail??
      I mean we have not defined tail??

    • @madsxcva
      @madsxcva 7 ปีที่แล้ว

      just as you save in head the first node of the list,
      in tail you save the last node of the list

    • @lohithnnegalur2018
      @lohithnnegalur2018 4 ปีที่แล้ว

      tail is pointer to last node , but we have only pointer to head node so we need to use a loop to go to last node assign pointer to it as tail and while(tail!=null){
      print(tail.data);
      tail=tail->prev;
      }

  • @amitpandey359
    @amitpandey359 8 ปีที่แล้ว

    that was really amazing, .
    BUT I AM QUITE WEAK AT THE BASICS, IS THERE ANY VIDEO OF YOURS WHICH WILL HELP ME CLEARING ALL MY BASICS FOR DATA STRUCTURES.

  • @SachitSharmadtu
    @SachitSharmadtu 10 ปีที่แล้ว +6

    lecture on circular linklist is not present i n these lecture.
    would you add them later ??

    • @thebaulbull
      @thebaulbull 10 ปีที่แล้ว

      Hey ... are u facing some issues... U can contact me

    • @SachitSharmadtu
      @SachitSharmadtu 10 ปีที่แล้ว

      Sir I was struggling initially but know I have understood the concept
      Thanks

    • @karankapoor2116
      @karankapoor2116 10 ปีที่แล้ว

      did you find the lesson on cicular linked list ?

    • @jaswinders2670
      @jaswinders2670 4 ปีที่แล้ว +1

      @@thebaulbull how to contact you

  • @AnkitJha07
    @AnkitJha07 8 ปีที่แล้ว

    /Inserting at end
    void insertAtEnd(int x)
    {
    struct node* newNode= (struct node*)malloc(sizeof(struct node));
    newNode->data=x;
    newNode->next=NULL;
    newNode->prev=NULL;
    if(head==NULL)
    {
    head=newNode;
    return;
    }
    struct node* temp= head;
    while(temp->next!=NULL)
    {
    temp=temp->next;
    }
    temp->next=newNode;
    newNode->prev=temp;
    }
    //End of inserting function.

  • @siddharthmagadum16
    @siddharthmagadum16 4 ปีที่แล้ว

    Thank you very much... 👍

  • @cheems08213
    @cheems08213 4 ปีที่แล้ว

    thanks animesh