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

  Рет қаралды 4,758

Nikhil Lohia

Nikhil Lohia

Күн бұрын

Deleting a node in a linked list primarily consists of identifying the node to be deleted and then updating the pointer of the previous node. Once the node is free, the programming language marks it free for use by other applications. Based on this idea, the video shows how you can delete a node from the beginning, from the end and from the middle. You will also find code samples for each of the use cases implemented in JAVA
Chapters:
00:00 - Intro
00:39 - General idea to Delete a node
02:34 - Delete from Beginning
03:25 - Code to delete a node from beginning
04:25 - Delete from End
05:12 - Code to delete a node from end
07:28 - Delete from Middle
08:17 - Code to delete a node from middle
11:00 - Final Thoughts
📚 Links to topics I talk about in the video:
Linked List: • Linked List Data Struc...
Array Data Structure: • Array Data Structure e...
📘 A text based explanation is available at: studyalgorithms.com/link_list...
Code on Github: github.com/nikoo28/java-solut...
📖 Reference Books:
Starting Learn to Code: amzn.to/36pU0JO
Favorite book to understand algorithms: amzn.to/39w3YLS
Favorite book for data structures: amzn.to/3oAVBTk
Get started for interview preparation: amzn.to/39ysbkJ
🔗 To see more videos like this, you can show your support on: www.buymeacoffee.com/studyalg...
🎥 My Recording Gear:
Recording Light: amzn.to/3pAqh8O
Microphone: amzn.to/2MCX7qU
Recording Camera: amzn.to/3alg9Ky
Tablet to sketch and draw: amzn.to/3pM6Bi4
Surface Pen: amzn.to/3pv6tTs
Laptop to edit vidoes: amzn.to/2LYpMqn
💻 Get Social 💻
Follow on Facebook at: / studyalgos
Follow on Twitter at: / studyalgorithms
Follow on Tumblr at: / studyalgos
Subscribe to RSS feeds: studyalgorithms.com/feed/
Join fan mail: eepurl.com/g9Dadv
#datastructures #programming #linkedlist

Пікірлер: 20
@chvilohith4133
@chvilohith4133 8 ай бұрын
honestly speaking ur the best guy in KZbin till today who thought the linked list so easily and with minimum time
@asmadik4
@asmadik4 11 ай бұрын
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 10 ай бұрын
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 жыл бұрын
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.
@pareshhere
@pareshhere 10 ай бұрын
nicely explained thanks
@nageshnimmala3200
@nageshnimmala3200 2 жыл бұрын
Tq for your effort to make it easy
@sourabhajoshi2129
@sourabhajoshi2129 5 ай бұрын
very nice.. Thank you
@deepeshreddy4700
@deepeshreddy4700 3 жыл бұрын
Thanks Man
@sharminator5227
@sharminator5227 16 күн бұрын
sir at 10:14 the loop should run till i < pos - 2 and not till pos - 1 . Please can you check it once ?
@Ocean_Tales_
@Ocean_Tales_ 5 ай бұрын
thanks !
@deepeshreddy4700
@deepeshreddy4700 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.
@amirhossein8956
@amirhossein8956 Жыл бұрын
Great
@mdmursalin4546
@mdmursalin4546 2 жыл бұрын
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.
@infinite639
@infinite639 Жыл бұрын
circular linked list please teach
@nikoo28
@nikoo28 Жыл бұрын
I will add a video on circular linked list
@soothingminds8866
@soothingminds8866 6 ай бұрын
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; }
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 25 МЛН
Secret Experiment Toothpaste Pt.4 😱 #shorts
00:35
Mr DegrEE
Рет қаралды 38 МЛН
I'm Excited To see If Kelly Can Meet This Challenge!
00:16
Mini Katana
Рет қаралды 29 МЛН
Я обещал подарить ему самокат!
01:00
Vlad Samokatchik
Рет қаралды 9 МЛН
Why The Windows Phone Failed
24:08
Apple Explained
Рет қаралды 220 М.
Single Linked List (Deleting the Node at a Particular Position)
9:43
Heartwarming Unity at School Event #shorts
00:19
Fabiosa Stories
Рет қаралды 25 МЛН