Deleting a Node in a Linked List | Animations, Examples and Code | Study Algorithms

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

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

  • @chvilohith4133
    @chvilohith4133 11 месяцев назад +2

    honestly speaking ur the best guy in RUclips till today who thought the linked list so easily and with minimum time

  • @AiCorrales
    @AiCorrales Месяц назад

    Nikhil Lohia is the GOAT. I once saw him save a entire family from a burning car after saving a drowning puppy. He also helped me get through my Grad CS class. Thank you Nikhil, you are everyone's hero.

  • @asmadik4
    @asmadik4 Год назад +5

    Hey Nikhil,
    I have seen some of your videos. Your videos are really great. Your way of speaking, your pace and style of explaining any problem is marvelous.
    Thanks for the detailed explanation. 🖖🤩
    However just a note for this deletion video here and the other insertion one, while deleting/adding the node from/to the link, you considered the index from 1 while explaining, but from coding perspective, it starts from 0. 🙂

    • @nikoo28
      @nikoo28  Год назад

      thanks for your feedback and motivation. I understand the confusion it might have caused. Sometimes, it is easier to explain in a certain way and writing code in the other. I will try to clear things up more in my upcoming videos.

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

    thanks, Nikhil, you have made, SLL so simple, now i can visualize things related to SLL. thanks, bro

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

      Thank you so much. Always remember, visualisation of any problem helps to understand better 😄

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

      @@nikoo28 thanks, nikhil, bro, I want more favor from you side coz its magnetic what you teach, that, similar to SLL and DLL, please make complete videos on Arrays 1D and 2D, strings, recursion , two pointers, hashing, bit manipulation, etc, concept, syntax and dry run. And , club all questions in a separate video, so that, all concept learn in one and practice them in another. It will synchronize our concept building. Array and string videos you uploaded, are just one. I hope u got the point. Coz , I want to DSA once and forever and no other good source m looking now other than you which fill the gap. So brother just come up with that. Thanks.

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

    Tq for your effort to make it easy

  • @sharminator5227
    @sharminator5227 3 месяца назад

    sir at 10:14 the loop should run till i < pos - 2 and not till pos - 1 . Please can you check it once ?

  • @pareshhere
    @pareshhere Год назад

    nicely explained thanks

  • @deepeshreddy4700
    @deepeshreddy4700 3 года назад +3

    how to pass parameters from main method to delete the values it's not present in your code

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

      that would mean deleting a value, thanks...I will cover that portion in another video soon.

  • @sourabhajoshi2129
    @sourabhajoshi2129 8 месяцев назад

    very nice.. Thank you

  • @mdmursalin4546
    @mdmursalin4546 2 года назад +1

    Why do we return head from the method ?

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

      That is because we can only refer a single linked list from the head pointer.
      If we return any other node, the head will be lost.

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

    Thanks Man

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

    thanks !

  • @amirhossein8956
    @amirhossein8956 Год назад

    Great

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

    circular linked list please teach

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

      I will add a video on circular linked list

  • @soothingminds8866
    @soothingminds8866 9 месяцев назад +1

    public ListNode deleteAtMiddle(ListNode head, int position) {
    ListNode ptr = head;
    // If position is 1, call deleteAtBeginning and return its result
    if (position == 1) {
    return deleteAtBeginning(head);
    }
    // Move to the node before the one to be deleted
    for (int i = 0; i < position - 2; i++) {
    ptr = ptr.next;
    }
    // Get the node to delete
    ListNode nodeToDelete = ptr.next;
    ListNode nextNode = nodeToDelete.next;
    // Point the next of ptr to nextNode
    ptr.next = nextNode;
    return head;
    }