Delete last node of a Singly Linked List in Java (Animation)

  Рет қаралды 27,194

Dinesh Varyani

Dinesh Varyani

Күн бұрын

Пікірлер
@itsdineshvaryani
@itsdineshvaryani 4 жыл бұрын
Please *Like* , *Comment* , *Share* , *Subscribe* and *Click Bell* 🔔🔔🔔 Icon for More Updates. To get *Data Structures and Algorithms* complete course for free please follow this link - kzbin.info/aero/PL6Zs6LgrJj3tDXv8a_elC6eT_4R5gfX4d
@jaspalsingh-mv5xh
@jaspalsingh-mv5xh 3 жыл бұрын
👍
@shubhamagarwal1434
@shubhamagarwal1434 2 жыл бұрын
Best series for DS & Algo. I am also 10 yrs java exp guy. Was looking for DS & Algo free course over KZbin with java implementation and found this. Hats Off To You Man...Excellent Work. GOD BLESS YOU :)
@itsdineshvaryani
@itsdineshvaryani 2 жыл бұрын
Thanks !!!
@anantkashyap2087
@anantkashyap2087 3 жыл бұрын
sir your channel is a boon for the data structure learners ,with java as their programming language .I wonder why this channel is not among the most viewed channels on youTube ...because no one makes such a value adding quality content .. Your work is amazing sir ...the day is not soo far when you will get lakhs or millions of views on your channer ...Thankyou so much sir, continue making videos like this sir ..we love it
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
Thanks for such a wonderful comment. I request you to like each video you watch on my channel. Also, please share the course with ur friends and colleagues on whatsapp, FB, Linkedin etc. It will help the channel grow and allow me to add more such content.
@anantkashyap2087
@anantkashyap2087 3 жыл бұрын
Sir I have watched almost 40-50 video including trees,graph linkeslist,heap and priority queue ...and liked almost every video which I saw ....and had shared it on whatsapp and Facebook ...will share it soon on Linkedin sir ......your content is worth sharing and viewing ♥️
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
@@anantkashyap2087 thank you so much !!!
@sanchitjain9745
@sanchitjain9745 3 жыл бұрын
good content for the last minute preparation....loved it
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
Thanks !!!
@soumyadipmajumder902
@soumyadipmajumder902 Жыл бұрын
Really enjoying your course, Thank you sir for the course
@itsdineshvaryani
@itsdineshvaryani Жыл бұрын
You are very welcome
@Rahulkumar-dm4zu
@Rahulkumar-dm4zu 2 жыл бұрын
Hi @Dinesh Varyani, This code will not work if SinglyLinkedList has only one node say head as you are not nullifying the reference of head to null, instead you are just returning the head. In this case SinglyLinkedList will always have the one node i.e. head. So no deletion will take place. Please correct me if I am wrong. Thanks,
@priyanshu_choudhary_
@priyanshu_choudhary_ Жыл бұрын
if(head.next== null){ ListNode temp = head; head = null; return temp; }
@tonyseben
@tonyseben 8 ай бұрын
True. Without the head = null, the LL will never be able to delete the final node.
@omeruluyagmur
@omeruluyagmur 3 жыл бұрын
I didn't understand how the last node was deleted, because at the end of the code blocks it only returns current node but current node does not contains entire LinkedList.
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
you can return head ... currently algo returns deleted node !!!
@_PRACHIGHARDE
@_PRACHIGHARDE 3 жыл бұрын
We can directly do like--> if(head==null || head.next==null) { return null; } else { while(currNode.next.next!=null) { currNode=currNode.next; } currNode.next=null; return currNode; }
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
check for null pointer exception ... if it works ... it could be one way !!!
@_PRACHIGHARDE
@_PRACHIGHARDE 3 жыл бұрын
@@itsdineshvaryani yes it works..
@shashanksheelwant5273
@shashanksheelwant5273 2 жыл бұрын
you have to return deleted node not the current node ,for that case@1655_PRACHI GHARDE your code won't work.
@prakharrana8384
@prakharrana8384 3 жыл бұрын
thanks sir
@dagaprerna
@dagaprerna 3 жыл бұрын
When you return head when head.next= null, why are you not doing head =null?
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
hmm could be done ... depending on scenario u trying to achieve !!!
@leoking2386
@leoking2386 3 жыл бұрын
If we only have a head element then it is the first and last element. So shouldn't we delete that element and return the head as null?
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
we shd delete that node as well !!!
@jaspalsingh-mv5xh
@jaspalsingh-mv5xh 3 жыл бұрын
Nice
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
Thanks
@jaspalsingh-mv5xh
@jaspalsingh-mv5xh 3 жыл бұрын
Nuce
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
Thanks. I request you to like every video you watch in the series, share this playlist with ur friends and colleagues and ask them to do the same. It will help the channel grow and motivate me to add more such content. Thanks !!!
@modinglymods4085
@modinglymods4085 Жыл бұрын
@omeruluyagmur
@omeruluyagmur 3 жыл бұрын
This code can also run but I cannot understand how it works. public void deleteLast(){ if (head==null ||head.next==null) return; Node current=head; Node previous=null; while (current.next!=null){ previous=current; current=current.next; } previous.next=null; }
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
previous reference is needed to remove current node ... after while loop ends current is at last node and previous is second last ... you can set previous.next to null to remove current node.
@puneetkumar7121
@puneetkumar7121 3 жыл бұрын
hii sir job lgva do
@itsdineshvaryani
@itsdineshvaryani 3 жыл бұрын
Hehehe !!!
Delete last node of a Singly Linked List in Java (Implementation)
7:33
Insert a node in a Singly Linked List at a given position (Animation)
15:33
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН
Noodles Eating Challenge, So Magical! So Much Fun#Funnyfamily #Partygames #Funny
00:33
How to delete first node in a Doubly Linked List in Java ?
15:18
Dinesh Varyani
Рет қаралды 27 М.
Introduction to Linked Lists (Data Structures & Algorithms #5)
18:47
Learn Linked Lists in 13 minutes 🔗
13:24
Bro Code
Рет қаралды 350 М.
Recursive PreOrder traversal of a Binary Tree in Java
26:06
Dinesh Varyani
Рет қаралды 61 М.
LinkedList vs ArrayList in Java Tutorial - Which Should You Use?
11:43
Coding with John
Рет қаралды 608 М.
LinkedList 7 removeLast()
11:58
RobEdwards
Рет қаралды 11 М.
Кто круче, как думаешь?
00:44
МЯТНАЯ ФАНТА
Рет қаралды 6 МЛН