Doubly Linked List - Implementation in C/C++

Поделиться
HTML-код
  • Опубликовано: 20 окт 2024

Комментарии • 281

  • @kunal1035
    @kunal1035 3 года назад +33

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

  • @nguaial8490
    @nguaial8490 8 лет назад +52

    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!

  • @kanishkjain2767
    @kanishkjain2767 5 лет назад +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

  • @mymanhapt
    @mymanhapt 8 лет назад +17

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

  • @pranavofindia
    @pranavofindia 6 лет назад +254

    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 5 лет назад

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

    • @lasyagajavelli594
      @lasyagajavelli594 5 лет назад +1

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

  • @zeeshanayub9706
    @zeeshanayub9706 7 лет назад +8

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

  • @TheHyperActiveRedditBot
    @TheHyperActiveRedditBot 2 года назад +4

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

  • @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!

  • @bhavanababua959
    @bhavanababua959 3 года назад +1

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

  • @maliksaraanasim5404
    @maliksaraanasim5404 5 лет назад +1

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

  • @firkyunbanaya
    @firkyunbanaya 7 лет назад +1

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

  • @anusrees3991
    @anusrees3991 7 лет назад

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

  • @antor.morsalin
    @antor.morsalin Год назад +2

    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.

  • @scotfsh5014
    @scotfsh5014 2 года назад +2

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

  • @Facttoknowabout
    @Facttoknowabout 6 месяцев назад

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

  • @AlphaZubair
    @AlphaZubair 7 месяцев назад

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

  • @毛喬-o6t
    @毛喬-o6t Год назад +1

    this is the best DS video i have ever seen

  • @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]

  • @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!

  • @pcpardon
    @pcpardon 3 года назад +1

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

  • @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 :)))

  • @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.

  • @TheFlexath
    @TheFlexath 7 месяцев назад

    the best data structures playlist ever!

  • @asmereg
    @asmereg 3 года назад

    Such a great teacher! Please come back

  • @mohitsrvv
    @mohitsrvv 3 года назад

    many years but still watching thanks

  • @abhirupbasak5035
    @abhirupbasak5035 4 года назад

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

  • @danielabonvini2936
    @danielabonvini2936 7 лет назад +2

    Thank you, finally getting to understand how DLL work

  • @lucafrazz6199
    @lucafrazz6199 8 лет назад +2

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

  • @meghamalviya8495
    @meghamalviya8495 5 лет назад

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

  • @antragupta1001
    @antragupta1001 6 лет назад

    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 ...
    😍😍😍

  • @rabinrai5838
    @rabinrai5838 7 лет назад +12

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

  • @ucthuanphung4530
    @ucthuanphung4530 6 лет назад +1

    Videos are extremely clear and useful. Thanks a lot.

  • @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.

  • @dheerajdhall8482
    @dheerajdhall8482 8 лет назад

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

  • @renelhomere5243
    @renelhomere5243 8 лет назад +2

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

  • @anandsatija6172
    @anandsatija6172 7 лет назад +27

    guru dronacharya of data structure :)

  • @findoc9282
    @findoc9282 3 года назад

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

  • @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?

  • @kuonkhailechdawech2309
    @kuonkhailechdawech2309 Год назад +1

    You're legend brother 🙏

  • @poojagoyal869
    @poojagoyal869 7 лет назад +1

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

  • @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.

  • @arpitj795
    @arpitj795 8 лет назад

    thank you for making things simpler.

  • @Maurin4000
    @Maurin4000 9 лет назад

    best explanation so far, thx a lot

  • @akashdeep504
    @akashdeep504 9 лет назад +7

    please upload some lectures on dynamic programming

  • @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/

  • @harshitsoora1313
    @harshitsoora1313 6 лет назад

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

  • @sreekumarmenon
    @sreekumarmenon 10 лет назад +15

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

    • @mycodeschool
      @mycodeschool  10 лет назад +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.

  • @vijaymalawadkar6830
    @vijaymalawadkar6830 6 лет назад

    Thank you for easy explanation of linked list

  • @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 ... ?

  • @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

  • @rafay1067
    @rafay1067 3 года назад

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

  • @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.

  • @wannabe.explorer
    @wannabe.explorer 8 лет назад

    cleared my concept..thanks sir!!

  • @daoanhtuandao8106
    @daoanhtuandao8106 7 лет назад

    your videos are helpful .I learned more good knowledge .

  • @bleep4930
    @bleep4930 8 лет назад

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

  • @Mhmoudko
    @Mhmoudko 9 лет назад

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

  • @ricardohincapie1537
    @ricardohincapie1537 4 года назад

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

  • @roopanrodin7924
    @roopanrodin7924 6 лет назад

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

  • @narapareddy8256
    @narapareddy8256 Месяц назад +1

    nice explation sir . from iit bombay cse

  • @AdityaPratapsingh9125
    @AdityaPratapsingh9125 8 лет назад

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

  • @Nino-bd7bp
    @Nino-bd7bp 7 лет назад +1

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

  • @senku3288
    @senku3288 4 года назад

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

  • @lilianawong4819
    @lilianawong4819 5 лет назад +1

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

  • @mirzaavez6284
    @mirzaavez6284 9 лет назад

    Thanks sir for explaining this topic

  • @Christine-ne3dw
    @Christine-ne3dw 4 года назад

    Thanks, I appreciated this a lot.

  • @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.

  • @mattm32
    @mattm32 4 года назад

    Thanks you for this wonderful video, how do we modify the code to use it us generic list, i try to use void pointer but i got an error on type casting it bc the data types can different in the same list?
    Thanks again!!!

  • @TheDigitalPedia
    @TheDigitalPedia 8 лет назад

    Great stuff you guys are producing i must say.
    Have you guys posted videos on priority queues+heaps and Graphs?? If yes so any link you can provide?

  • @machinelearning3518
    @machinelearning3518 3 года назад

    i'm grateful for ur video

  • @Amitpattel1
    @Amitpattel1 8 лет назад

    hi your video is very help ful to me can you please tell me what editor is you where using thanks

  • @095_shaniabalkhi9
    @095_shaniabalkhi9 3 года назад

    Great explanation!

  • @anandsatija6172
    @anandsatija6172 7 лет назад

    sir ji u r great teacher

  • @RatIceCream
    @RatIceCream 2 года назад

    Thanks for uploading!

  • @nayeemsunny2573
    @nayeemsunny2573 6 лет назад

    hello sir ,thank you for providing this videos. I didn't find videos of circular linked list could you please upload them.Thank you.

  • @abhiseksen1817
    @abhiseksen1817 10 лет назад +2

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

  • @Rizzan8
    @Rizzan8 7 лет назад +2

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

  • @yichizhang795
    @yichizhang795 9 лет назад

    Good work sir, Thanks!

  • @yashkothari7540
    @yashkothari7540 7 лет назад +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.

  • @yogabrindha5640
    @yogabrindha5640 3 года назад

    Clean explaination

  • @krishnaindani8414
    @krishnaindani8414 8 лет назад

    Do you guys have the tutorials for python ?
    Your tutorials are awesome...but i need it in python

  • @CODINC
    @CODINC 7 лет назад

    Absolutely Amazing man!!!

  • @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;
    }
    }

  • @manansatra
    @manansatra 7 лет назад

    Hi, you said that the newNode in GetNewNode is local to GetNewNode but previously you mentioned that the output or the node we get from the malloc function or new Node is global and so the newNode variable were we store the result of malloc should also be global. I am confused and the statement seems contradictory to me. Could you please help me with my confusion? Thanks.

  • @dimaibo3565
    @dimaibo3565 8 лет назад

    Thank u very much, can i get answers if i asked about the above code please?

  • @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 9 лет назад

      did you find the lesson on cicular linked list ?

    • @jaswinders2670
      @jaswinders2670 4 года назад +1

      @@thebaulbull how to contact you

  • @dhruvgaba865
    @dhruvgaba865 5 лет назад

    nice explanation

  • @MrBomer213
    @MrBomer213 5 лет назад

    hello thank you foe the video its awesome!
    i have a question and its killing me, at 8:32 you're inserting InsertAtHead(2) and InsertAtHead(4) but in your drawing you have '2' in address 400 and '2' in address in 600 did you mean to put 4 ?? or are we replicating the Head with the val 2?

    • @ishanpand3y
      @ishanpand3y 5 лет назад

      he mistakenly wrote 2 instead of 4

  • @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.

  • @deepanshubansal4454
    @deepanshubansal4454 9 лет назад +1

    my reverse print method does not work.plz tell me the mistake-
    void revprint(node **firstnode)
    {
    node *n=*firstnode;
    while(n->next!=NULL)
    {
    n=n->next;
    }
    while(n!=NULL)
    {
    coutprev;
    }
    }

    • @2fast4uspartan
      @2fast4uspartan 8 лет назад

      seems correct. but u should check if n is NULL first.

  • @ChauTran-mh5qo
    @ChauTran-mh5qo 6 лет назад

    Hi bro,
    When you implement the function "InsertAtHead(int x)", why don't we use the following implementation
    //*********
    head -> prev = newNode -> next;
    newNode -> next = head -> prev;
    head = newNode;
    //*********
    I know that is incorrect, but can you help to clarify my misunderstanding.
    Thanks and Regards,

  • @MOHDNAVEED1
    @MOHDNAVEED1 11 лет назад

    awesome compilation

  • @sagarvyas304
    @sagarvyas304 9 лет назад

    in the 8.52 mins of the video we see how to add a new node to the non empty list. but we write
    1.head->prev=newnode;
    2.newnode->next=head;
    3.head=newnode;
    so my question is can we write newnode->next=NULL; instead of the 2nd statement?

  • @w4h175
    @w4h175 3 года назад

    hats off sir ji..

  • @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;
      }

  • @usama57926
    @usama57926 6 лет назад

    this tutorial is amazing

  • @RajahChandrasekhar
    @RajahChandrasekhar 5 лет назад

    Best tutorial ever!!!

  • @WinadiWiratama
    @WinadiWiratama 9 лет назад +1

    Sir, please do Doubly circular linked list, as you promise. Thanks!

    • @koulicksadhu7679
      @koulicksadhu7679 5 лет назад

      Did you find any? If yes, please share the links