Lecture 44: Linked List & its types - Singly, Doubly, Circular etc.

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

ความคิดเห็น • 1.4K

  • @AyushYadav-pk2hh
    @AyushYadav-pk2hh 2 ปีที่แล้ว +862

    It took me 10hrs to understand the concept of linkedlist but now I am fully confidence 🥺🥺🥺

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

      from where you have learnt? only through the video or from other resources too?

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

      *confident

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

      *confident

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

      @@playwithlogic okay. Thank you

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

      @@anonymous090 have you handled tail , when delete last node

  • @coderfek
    @coderfek ปีที่แล้ว +28

    Clean lectures. Just wanted to point out one thing. At 55:00 instead of initializing temp->next = NULL or curr->next = NULL , just interchange the two lines in the deconstructor code and put them in order so, this->next is first initialized to NULL and then its deleted. Thank you!

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

      Can u please explain me destructor code.🙏🙏

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

      @@devjindal8309
      ~Node()
      {
      int value=this->data;
      //Memory free
      if(this->next!=NULL)
      {
      this->next=NULL;
      delete next;
      }
      cout

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

      @@adnanahmad1234 ye to sir vala hi code hai explain to kar ise

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

      @@devjindal8309 this->data current node ke data ki value assign kar rha. aur if condition ye check kar rhi ki current pointer ka next node null hai ya nhi. agar null nhi hai to use null set kar de rha, means null set Karne ke baad pointer break ho gaya purane wale node se. phir humne delete next kya to dobara recursive call hua jisse subsequent node agar present hain wo free ho jaayein. I guess yahi hoga jitna much samajh aaya !!

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

      @@adnanahmad1234 @adnanahmad1234 humne delete next kyo kiya. Next me to agli Vali node ka address hai to next node delete hogi na usse to par hame to current node ko delete karna hai na so hamne delete this kyo nahi likha.

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

    The consistency and the content of this course is lit!!🔥🔥🔥

  • @therealartist9
    @therealartist9 8 หลายเดือนก่อน +67

    linked list is a hard topic for beginners and yaha par bhaiya ko thoda dheere dheere aram se dubara cheeze samjhana tha but bhaiya bhot fast chale gaye

    • @PIYUSHTAILORstillalive
      @PIYUSHTAILORstillalive 4 หลายเดือนก่อน +2

      Merko toh esa nhi lga bhai...maybe jab video dekhna is not enough ,thoda self research also helps

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

      Ha bhai

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

      @@tusharsingh3063 theek bhai. Koi specific doubt jo toh comment krdo..aata hoga toh help kr dengey

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

      bhai literally muje khudko vahi lag rha hai ki bhaiya thoda fast padha rhe hai

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

      Not good for beginners

  • @avishkarpatil5871
    @avishkarpatil5871 11 หลายเดือนก่อน +130

    Comment at 1:36:22- Don't forget this crucial edge case!
    Hey everyone, just a quick heads-up! In the code provided, there's a crucial edge case that was almost missed. To ensure the correct functioning of this deleteNode function, please remember to include the following line:
    if(curr->next != NULL){
    curr->next->prev = prev; // This line is essential to maintain the integrity of the linked list.
    }
    It's a small but important detail that should not be overlooked, especially when deleting a node from a doubly linked list. Happy coding!

    • @digvijaybhongale6807
      @digvijaybhongale6807 11 หลายเดือนก่อน

      can u tell its order

    • @anujrithalia7797
      @anujrithalia7797 10 หลายเดือนก่อน +8

      yah bro , i also came in comments sections to just see if anybody saw what i saw ....u are right its a small but big mistake

    • @GauravKumar-uj5dm
      @GauravKumar-uj5dm 9 หลายเดือนก่อน +1

      i also noticed this

    • @shubhamgaming1641
      @shubhamgaming1641 9 หลายเดือนก่อน +1

      yes bro

    • @yashkum095
      @yashkum095 9 หลายเดือนก่อน +5

      yeah that's what I thought, there are 4 pointers associated with that node, but he deleted just 3, I thought he might have missed it thinking of just the tail deletion case.

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

    Thanks bhaiya I never thought of writing codes of linked list myself.
    But now I am confident to do it

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

    i just love the way you teach and cleared all the the complex part with an ease. kudos to you

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

    Lecture 44 Attendance
    It is simply amazing you uploading 1 hour + content literally every other day

    • @vpnuser5399
      @vpnuser5399 9 หลายเดือนก่อน +1

      nearly 2.5 hour man

  • @shubhampatel_2745
    @shubhampatel_2745 ปีที่แล้ว +45

    1:35:38 here love bhaiya forgot to tell about we have to also change the curr -> next -> prev = prev we have to change this as well if we are deleting any middle node apart from this lecture is super duper Awesome. Love from Bottom Of My Heart.
    edit-> spelling correction.

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

      Yess sir

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

      Can someone please tell me whats wrong in my code for CLL? It doesnt add new element next to tail. For example in int main() I tried to insert node 5 next to node 3 but it doesnt work
      class node
      {
      public:
      int data;
      node* next;
      node(int data)
      {
      this -> data = data;
      this -> next = NULL;
      }
      ~node()
      {
      int val = this->data;
      if(this -> next!=NULL)
      {
      delete next;
      this -> next = NULL;
      }
      cout next = newnode;
      }
      }
      void printList(node* tail)
      {
      node* temp = tail;
      do
      {
      cout

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

      @@none2868 Error in do while loop. Make it-- while(temp != tail)

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

      if we do this , then we have to handle the deletion of tail separately because when we want to delete the tail node then we would not have curr->next->precv as there would be no next node

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

      👍

  • @vinayaksharma-ys3ip
    @vinayaksharma-ys3ip 2 ปีที่แล้ว +15

    Best Series....even better than many of the paid courses!!!

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

    finally completed this video....hats off to your hardwork 🙏🙏🙏🙏

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

    Finished today with my basics of linked list in Cpp

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

    ek baar mushkil lga shuru me bilkul smjh ni arha tha but dheere dheere confidence tha bhaiya haii smjh a jayega and dekho kuch 30 mins ki video k baad sb logic khud bnane agye!

    • @GoluSharma-ji6cw
      @GoluSharma-ji6cw 8 วันที่ผ่านมา +1

      Bilkul bas starting me hi samajhne me dikkat hoti hai

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

    Long videos are unintentionally scary imo. Though, you may upload as per your convenience but sooner if possible! Try to finish this course by March itself with a video per day because Placement season is almost there. I'm on a re-run of your videos with the homework and will catch up again to the current video in a few days! You keep up your consistency and we'll keep ours!

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

      Did you get the placement brother?

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

      @@vasulibhai5202 +1

    • @rohan3944
      @rohan3944 5 หลายเดือนก่อน

      Got placement?

    • @suvigyabasnotra7378
      @suvigyabasnotra7378 5 หลายเดือนก่อน

      @@rohan3944 Long ago! Right now in the office. 🫅🏻

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

    "Love babbar" is a Person who can teach anything to anybody in very easy way.

  • @bhavya_21_12
    @bhavya_21_12 8 หลายเดือนก่อน +3

    What i learnt: in the InsertAtMiddle function of linked list, if the position for new node to be inserted at is at the end,
    Then we have to take care of updation of our tail(if any) also in the function.
    for that, we just have to check that
    after while loop if temp->next==NULL
    If yes, then we just call InsertAtTail function
    And return

  • @AbdulManan-yx6yv
    @AbdulManan-yx6yv 2 ปีที่แล้ว +22

    At *55:00** - **55:30* After adding these line temp->next = NULL;
    and curr -> next = NULL;
    I think we don't need destructor after this.

    • @abhiramreddy416
      @abhiramreddy416 10 หลายเดือนก่อน +2

      yes but its done to save some memory by deleting the nodes that arent required to us

    • @shahidmoideen5286
      @shahidmoideen5286 9 หลายเดือนก่อน

      but bro the destructor would delete next only if this->next !=NULL right
      but we've already made curr->next=NULL @@abhiramreddy416

    • @parthdeshwal4419
      @parthdeshwal4419 6 หลายเดือนก่อน

      why can't we just delete the nodes rather than setting them to NULL

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

    Currently on your recursion videos. Will catch up soon! Thanks for your efforts💯🔥

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

    The best DSA course ever 🔥🔥 consistent from day one ❤️

    • @GauravYadav-wt2yw
      @GauravYadav-wt2yw ปีที่แล้ว

      Have you done this course completely?

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

      explain me, what is the use of destructor here??

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

      ​@@sourabhchouhan8449 for delete a node

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

      Instead of writing shouldn't we write and shift the line before . Any ideas anyone ?

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

      @@sourabhchouhan8449 destructor is used to remove the constructor that gets created automatically after creation of object but you need to call destructor when you make object dynamically but if the object created statically then there is no need to call destructor as constructor created after static declaration of object removes automatically after the last line of code.
      Correct me if i am wrong:

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

    LL is good concept and needs time to interpret as a beginner. i request sir to upload 1hr videos for concept related videos so that we get decent time to grasp it.
    💓

  • @govindSoni-v2h
    @govindSoni-v2h 8 หลายเดือนก่อน +2

    this concept is not so simple , but you make it simple

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

    You are GOD for beginners. 🎅
    Even a non-CS branch learner can develop a good understanding of DSA by watching your lectures.

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

    Rating : 5/5
    For your consistency and content of the video

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

    This type of dedication is needed I want in myself

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

    best video on youtube on linked list i watched u explain a concept easily and clearly keep making such type of video ..

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

    Watched 3 times then crystal 🔮 cleared the concept thank you @Love Babbar

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

    Best course seriously I had gone through many but this is superb thank u bro

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

    Did'nt fully understand LL at once but understood it clearly when implemented it myself.

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

    While deleting the node in between from DLL, apart from linking prev. node's next to the node after current node, you will also have to link that node after the current node to the previous node since its a DLL. current -> next -> prev = current -> prev.

    • @DeepakKumar-uh9yn
      @DeepakKumar-uh9yn 2 ปีที่แล้ว

      bhai DLL ka deletion ka code bhejo na ,I am unable to understand for the middle and last node in DLL deletion.

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

      this code will break for last node

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

      @@hitececourses4062 ha to last node ke liye if laga ke itna hi code likhenge jitna bhaiya ne likha hai

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

      @@DeepakKumar-uh9yn void deleteNode(int position,Node* &head ,Node* &tail){

      if(position ==1){
      Node*temp = head;
      temp->next->prev = NULL;
      head = temp ->next;
      temp->next = NULL;
      return;
      }

      else{

      Node* curr = head;
      Node* previous = NULL;
      int cn =1;
      while(cnnext;
      cn++;
      }
      if(curr->next == NULL){
      //setting previous -> next = current -> next = NULL;
      previous->next = curr->next;
      //broking the link between current node and the previous node;
      curr->prev = NULL;
      //updating the tail to the previous node;
      tail = previous;
      delete curr;
      return;
      }
      //for deleting between the elements;
      curr->prev = NULL;
      previous->next = curr->next;
      curr->next = NULL;
      delete curr;
      }
      }

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

      after performing operation cout data

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

    Kaafi lambi video thi but finally complete kar li 4 to 5 hours mai with notes and codes 🤗 thank you for outstanding video 😍 Explored so many video but itna knowledgeable video nahi mila koi bhi 🤩
    Bus notes available karado bhaiya 🙏🏻really help ho jaayegai 😇

  • @gauravpawar5409
    @gauravpawar5409 10 หลายเดือนก่อน +2

    Searching for the best lecture for linked list and got this best video..........
    Thank you sir 🤩🤩

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

    At 57:20, while deleting if we delete the last node then tail points to an absurd location and tail->data will give error. Before doing prev->next=curr->next, apply this
    if(curr->next == NULL)
    {
    tail=prev;
    }

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

      This Doesn't work for me

    • @abhisheknigam2278
      @abhisheknigam2278 11 หลายเดือนก่อน

      @@adityaraj04 pass the tail as an argument in deletenode function and check it.

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

    Best DSA course available on TH-cam right now 🔥🔥🔥...
    Hats off Bhaiya

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

    The best DSA course ever 🔥🔥 consistent from day one

  • @JalalUddinMdAkbar-tc5ds
    @JalalUddinMdAkbar-tc5ds 2 ปีที่แล้ว +10

    you deserve atleast 5 million subs brother, really appreciate your work! Thank you from Bangladesh

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

    Bhaiya jitne din nhi daal paye the aap video, use compensate kar dia is video ne, it took me about 3 days to finish grasping content with hands on and understanding. I always feared LL. Waiting to get better at it. :) Thank you for your efforts.

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

    At 55:14 , i think code of destructor is wrong....bcz in the loop of destructor you are deleteting the node which is pointed by next but you have to delete the next node....thats why you got those errors but you are changeing your next to null before reaching destructor......thats why the loop of destructor will never get in run.

  • @focus.placement5589
    @focus.placement5589 2 ปีที่แล้ว +1

    Thankyouuu bhaiya... 2 baar dekha tho poora clear

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

    Bhaiya aapne jo dsa course banaya hai vo kisi bhi paid course main bhi itane achhe se nahi samjhaya hai thanks bhaiya course free main provide karne ke liye ♥️♥️♥️♥️

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

    Easiest video to understand about Linked list. Thank you so much bhaiya.

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

    I have a suggestion for InsertAtTail:
    void InsertionAtend(Node* &head ,int data){
    Node * ptr = head;
    while(ptr->next!=NULL){
    ptr = ptr->next;
    }
    Node*temp = new Node(data);
    temp->next=NULL;
    ptr->next = temp;
    }
    in this case we have no updation of tail when we are inserting from mid or head

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

      Wow , i was having mistake here thank you for this suggestion

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

    For handling Tail:
    Hint : wite this inside while loop
    if(curr -> next == NULL){
    tail = prev; // if the next is null and current node is to be deleted then the tail becomes the previous element
    }

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

    Delete ka distructor likhna jaruri hai kya ?
    delete temp ; se nahi ho jayega delete.

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

    Subah se lga hoon abb jake single list samajh aaya hai ....vo bhi Cristal clear......(*first time reading about linked list)
    🥲☺️

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

    best youtube channel i recommend to my friends.thanku bhaiya for such a course

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

    I think that in deleting simply linklist, destructor code is wrong because if we already do deletingnode->nest = null in code then what need of destructor code at 49:50 .

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

    Thankyouuuuu, Bhaiya for this video but please wait for two days to upload the next video. I am loving your teaching! You are the best DSA teacher ever. ❤

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

    1:38:00 In deletion of any middle node in Doubly Linked List why don't we did
    curr->next->prev=NULL;

    • @AMITKUMAR-bl6ke
      @AMITKUMAR-bl6ke 2 ปีที่แล้ว

      if(curr->next!=NULL){
      curr->next->pre=curr->pre;
      }

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

    Bhaiya well done bhaiya. So nice of you to be doing things so well!!

  • @SriniVas-mx1li
    @SriniVas-mx1li 2 ปีที่แล้ว +5

    Respect bhai for your dedication level 🔥

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

    1:36:48
    Tail case :
    if (curr->next == NULL)
    {
    Node *temp = tail;
    tail = curr->prev;
    }

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

    nice and informative video bhaiya hope your community and youtube videos reach max!!! lots of love from tamilnadu!!

  • @AdnanKhalid-n8z
    @AdnanKhalid-n8z วันที่ผ่านมา

    sir, Thanks a lot for this all.
    May Allah bless you with all that is better for you , and protect you from all that is harmful for you.

  • @MohdAmaan-on8td
    @MohdAmaan-on8td 2 ปีที่แล้ว +5

    Thanku so much Bhaiya ....for this lovely and consistent course🥰🥰

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

    bhaiya isi ki jarurat thi thankyou so much>>>

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

    Wow, great great lecture Bhaiya, lot's of love and gratitude!
    However at the deletion of a node part of the lecture, you first made that destructor code using
    if(this->next!=NULL) logic, however when you made the next pointer of the this object NULL before calling the destructor, you have in turn made the if statement redundant, right? Since now whenever this->next is checked, it will come as next and the if statement will be skipped entirely. So, what is the use of writing the if statement in the first place? When you didn't make the next pointer NULL before sending it, what you triggered was a type of recursion, because when you deleted the this->next value, that also triggered the destructor.
    So, the if statement of the destructor can be skipped entirely, right?

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

    1:35:10 , I think you have to also change the previous data of next node of current node in doubly linked list

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

      yes,
      current->prev=NULL;
      previous->next=current->next;
      current->next->prev=previous;
      current->next=NULL;

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

      @@diveshkumar3823 yes I think this is the right code for this problem

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

      yes bro, I think he missed it.

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

      @@diveshkumar3823 yes ,u r correct

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

    Was eagerly waiting for linked list 🎉🙏

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

    void deleteElement(Node * &tail,Node* &head, int position, int cur = 1){
    if (position == 1 ){
    Node * temp = head;
    head = head->next;
    temp->next = NULL;
    delete temp;
    }
    else{
    Node * curr = head;
    Node * temp = NULL;
    int cnt = 1 ;
    while (cnt < position){
    temp = curr;
    curr = curr->next;
    cnt++;
    }
    temp->next = curr->next;
    curr->next = NULL;
    if (temp->next == NULL){
    tail = temp;
    }
    delete curr;
    }
    }
    Home work done bhai !! mast video , was struggling with linked list but now I think I can use it properly and have understood the concept and code .

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

    Thanks a lot for such a quality explanation

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

    Thank You Bhaiya for this amazing course🥰

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

    instead of writing temp->next = NULL and curr->next=NULL we should simply change the destructor code like this :
    ~Node()
    {
    int value=this->data;
    // memory free
    if(this->next!=NULL)
    {
    this->next=NULL;
    }
    cout

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

      Can you explain how destructor is working when the node next is already NULL plzz🙏🏻🙏🏻🙏🏻🙏🏻

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

      in this video if condition is wrong which is (this->next==NULL) and you have to delete just a pointer variable which is next not 'this', "this" pointing the actual data which is static and you have to delete manually just a dynamic variables not static variables in c++ i hope you getting my point 😀

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

      @@marveldbs3001 in this video if condition is wrong, right one is which is (this->next==NULL)

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

    58:40 here we pass the tail as ref argument and if prev->next == NULL then tail = prev; delete curr;
    ....rest of the code
    while (count < position)
    {
    prev = curr;
    curr = curr->next;
    count++;
    }
    prev->next = curr->next;
    curr->next = NULL;
    if (prev->next == NULL) {
    tail = prev;
    }
    delete curr;
    }

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

      thanks :)

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

      still garbage value

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

      @@surajrajaram8115 void deleteAtPosition(Node *&head, Node *&tail, int position)
      {
      if (position == 1)
      {
      Node *temp = head;
      head = head->next;
      // Memory free
      temp->next = NULL;
      delete temp;
      }
      else
      {
      Node *curr = head;
      Node *prev = NULL;
      int counter = 1;
      while (counter < position)
      {
      prev = curr;
      curr = curr->next;
      counter++;
      }
      prev->next = curr->next;
      curr->next = NULL;
      if (prev->next == NULL)
      {
      tail = prev;
      }
      delete curr;
      }
      }

    • @M.YASIR_SHAHZAD
      @M.YASIR_SHAHZAD 4 หลายเดือนก่อน

      yar ya kar ka dakha ha but nai work nai kar rha ha

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

      if(temp->next==NULL){
      Node* newNode = new Node(d);
      temp->next = newNode;
      tail = newNode;
      //insertAtTail(tail,d);
      return; add this to inserAtPosition() instead of inserAttail()

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

    during deletion of node in doubly linked list you haven't changed the cur->next->prev it is still pointing to that deleted memory block

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

      but after changing cur->next->prev=prev there is no output

  • @ashreekar4896
    @ashreekar4896 4 หลายเดือนก่อน +1

    In circular linked list if we give a element to refer which is not in the list then code will run forever so for safety also add current ->next != tail inside while loop

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

    Very Supportive classes bhaiya and best content in you tube AND also a great quote in description. 3 IN 1

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

    One of the best course of DSA on youtube❤

  • @AkhtarKhan-gk6ot
    @AkhtarKhan-gk6ot ปีที่แล้ว +9

    58:50 Homework : Last Node Deletion how to place tail at right position
    void deleteNode(Node *&head, Node *&tail, int pos)
    {
    // Deleting Start or First Node
    if (pos == 1)
    {
    Node *temp = head;
    head = head->next;
    temp->next = NULL;
    delete temp;
    }
    // Deleting Middle or end Node
    else
    {
    Node *curr = head;
    Node *prev = NULL;
    int cnt = 1;
    while (cnt < pos)
    {
    prev = curr;
    curr = curr->next;
    cnt++;
    }
    prev->next = curr->next;
    curr->next = NULL;
    delete curr;
    // Placing Tail at it's right postion
    if (prev->next == NULL)
    {
    tail = prev;
    }
    }
    }

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

      I need help in coding question plz u help me ..? Telegram user id so I take help from u plz .

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

      tnx bhai for solution

  • @rachit_joshi
    @rachit_joshi 7 หลายเดือนก่อน +1

    Thank You So Much BHRATA SHREE !!!!

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

    Bhaiyaaaaà your course is of next level maan 😭. Trust me no one can beat you in this field and reach aaegi tagdi iss course ki. And thanks bhaiyaaaaa. Agr time mile to bhaiyaaa reply kr dena.. waiting for your reply

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

    wahh another anexciting session a lot of things i learned from this video sub achhe smja gya bhaiyaa...love u bhaiyaa❤❤

  • @Pikachu10-19
    @Pikachu10-19 2 ปีที่แล้ว +5

    Finally ,we are in the part I've beeen waiting for . Great consistancy bhaiya 🙂❤

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

    You are my favourite teacher

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

    Please explain that memory-free code in the destructor!! Content is amazing!!!

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

      1->2->3->4->5
      If we want to delete the 2nd position, then first, make '1' point to '3' then assign next of '2' as NULL.
      In case, we forget to make it null, according to this destructor, all the nodes next to '2' will also get deleted.
      Run this code for reference:
      #include
      using namespace std;
      class Node
      {
      public:
      int data;
      Node* next;
      Node(int d)
      {
      data = d;
      next = NULL;
      }
      ~Node()
      {
      int v = this->data;
      if(this->next != NULL)
      {
      delete next;
      next = NULL;
      }
      cout

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

      @@suchetapal713 how to update tail pointer in case of delete at end
      i update tail pointer as previous but that not working

    • @user-zg3ru3hs2j
      @user-zg3ru3hs2j 2 ปีที่แล้ว

      @@suchetapal713 in which concept or topic he explain about " ->" concept plz tell me

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

      @@Harshffx This is what I have written, u can compare with it, otherwise u can paste your code here
      void deleteNode(Node *&head, Node *&tail, int pos)
      {
      Node *prev = NULL;
      Node *current = head;
      int c = 1;
      if (head == nullptr)
      {
      return;
      }
      if (pos == 1)
      {
      head = current->next;
      current->next = NULL;
      delete current;
      return;
      }
      while (c next;
      c++;
      }
      if (current->next == NULL)
      {
      tail = prev;
      }
      prev->next = current->next;
      current->next = NULL;
      delete current;
      }

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

      @@user-zg3ru3hs2j You can refer to lecture 25 (Pointers) and then to lecture 42 (OOPs)

  • @ajaykushwaha-0108
    @ajaykushwaha-0108 ปีที่แล้ว

    Thank you bhaiya for this ! kaafi lambi video thi par mazaa aaya aur aage bhi aise padhte rahenge

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

    Currently on your LinkedList day 1 videos. I Will catch up soon! Thanks for your efforts💯🔥

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

      explain me, what is the use of destructor here in singly linked list??

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

      @@sourabhchouhan8449 no idea bro , he is confusing it too much

  • @AbdulManan-yx6yv
    @AbdulManan-yx6yv 2 ปีที่แล้ว +1

    1:38:00 In deletion of any middle node in Doubly Linked List why don't we did
    curr->next->prev=prev;? so that it points to the previous node and delete the middle element.
    curr->prev = NULL;
    prev->next = curr->next;
    curr->next->prev = prev;
    curr->next = NULL;
    delete curr;

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

    Your consistency and endless effort are really Apprecitable beyond words. 😍🥰...

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

    Outstanding lecture .. love from Bangladesh

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

    Thank you, man...
    For this great course, your teaching is Superb.
    Thank you again from the bottom of my heart🥰.

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

    Thara bhai babbar esi dsa pdhavega esi dsa pdhavega
    Kisi me sochi na hogii
    Btw love the content bhaiya
    Kafi confidence aya h ab que solving me 🥳

  • @Heartless-he8km
    @Heartless-he8km 2 ปีที่แล้ว +5

    can anybody explain what is happening at 1:33:03 , according to my knowledge he is supposed to assign NULL first and then delete. but he is doing opposite?

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

    Solution of tail capture garbage value when we delete last position.
    void delete_from_pos(node* &head,node* &tail,int pos)
    {
    node* curr=head;
    node* prev=NULL;

    if(pos==1)
    {
    head=curr->next;
    curr->next=NULL;
    delete curr;
    }
    else
    {
    int i=1;
    while(inext;
    i++;
    if(curr->next==NULL)
    {
    tail=prev;
    }
    }
    prev->next=curr->next;
    curr->next=NULL;
    delete curr;

    }

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

    Such a great lecture on Linked List.

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

    Sir i feel instead of adding these unnecessary lines at 55:20 in DelNode func
    we can directly write this logic in destructor
    ~Node(){
    int value=this->data;
    if(this->next!=NULL){
    this->next=NULL; ⬅
    delete next;⬅
    }
    cout

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

      Bro isne 24:35 print function kyo use Karo

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

      Bro why we use this->next!=NULL

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

    The best ever dsa course. ❤

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

    Pehle Linked list ke name se hi dar lagta tha ki kaise implement karna hai But Jis tarah se aapne padhaya hai voh dar chal gaya. Now i can solve any linked list problem. Thanks Bhaiya ❤️ for providing the best content.

  • @mr.umairkhan5981
    @mr.umairkhan5981 2 ปีที่แล้ว +5

    Great Tutorial looking to learn many more in future👍

  • @rohitchitampalle276
    @rohitchitampalle276 9 หลายเดือนก่อน

    perfect explanation of concepts and i coded in javascript ..♥

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

    What an explanation!! Thanks for such amazing content.

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

    Took many days to learn, but after understanding it's very easy,
    But it takes time to understand......

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

    Babbar bhaiya with a new Linked List video and New haircut: Mogambo khushh hua😂😂

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

    Babbar bhaiya..dhuaadhaar batting 🏏 karte hue!! 🔥🔥 Hum bhi nets me practice kar rhe hai bhaiya, jaldi hi ground pe jalwa dikhayenge!! ❤🤞

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

    Present sir 🔥🔥 most awaited topic !!!!

  • @gorilla_coder-el6kf
    @gorilla_coder-el6kf ปีที่แล้ว +1

    Instead of deleting the pointer and then calling the custom destructor of the node class you can directly let the global delete function do the job for you right? so that it directly frees up memory allocated to the curr node and then you don't have to set next pointer to NULL.

  • @HoorulainAsad
    @HoorulainAsad 5 หลายเดือนก่อน +3

    Better than college teachers with PhD degrees ❤❤❤

  • @abhishekjha0303
    @abhishekjha0303 8 หลายเดือนก่อน +1

    Nice explanation bhaiya 😀

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

    Bhaiya I have a doubt, whiling deleting the DDL if the curr node is any internal node then we should also add one line (1:35:49)(i think).
    if(curr->next!=NULL)
    curr->next->prev= prev;
    before the line curr->next = NULL;
    while checking through print function it does not create any mess as we are checking through next pointer in print function.

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

      bro plz tell me that how should I update the tail after deleting it

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

      i am finding comment that who have done like me and think like me and that is you are....🤣🤣🤣🤣🤣🤣🤣🤣✔✔✔✔

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

      @@dhruvdalal878 🤣🤣🤣

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

      @@dhruvdalal878 +1🤣🤣

  • @Leafffyy
    @Leafffyy 9 หลายเดือนก่อน

    thank you Bhaiyaa
    I understood LINKED LIST veryy well
    Thank you for making this DSA series it is really really good I also learned c++ from this and now I have confidence in coding

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

    Best DSA course ever🔥🔥🔥