Please *Subscribe* and *Click Bell* 🔔🔔🔔 Icon for More Updates. To get *Data Structures and Algorithms* complete course for free please follow this link - ua-cam.com/play/PL6Zs6LgrJj3tDXv8a_elC6eT_4R5gfX4d.html
Best series for DS & Algo. I am also 10 yrs java exp guy. Was looking for DS & Algo free course over UA-cam with java implementation and found this. Hats Off To You Man...Excellent Work. GOD BLESS YOU :)
I see many people learning DSA with C/C++, but I decided to learn it in JAVA for full stack development related opportunities. But the resources are very few for DSA in JAVA😶 Luckily I found this🤞. Thank you so much sir for giving some hope for many people like me...! Lastly, Thanks for spreading this Knowledge instead of selling it🤩👏👏👏. I will definitely share this with many👍 - Samanvitha : )
This will fail in case position specified is larger than the current list size. If list has 4 element and I asked to insert an element at position 8 then it will fail. Corner case needs to be considered
You can make the following changes in your code if you want to check if a given position is valid or not private void insertAtPosition(int value, int position, SinglyLinkedList singlyLinkedList){ ListNode node = new ListNode(value); if (position == 0 || position > singlyLinkedList.length()+1){ System.out.println("Error, Invalid Position"); return; } }
} } Exception in thread "main" java.lang.NullPointerException: Cannot read field "next" because "previous" is null at SinglyLinkedList.insert(SinglyLinkedList.java:40)
You can make the following changes in your code if you want to check if a given position is valid or not private void insertAtPosition(int value, int position, SinglyLinkedList singlyLinkedList){ ListNode node = new ListNode(value); if (position == 0 || position > singlyLinkedList.length()+1){ System.out.println("Error, Invalid Position"); return; } }
You can make the following changes in your code if you want to check if a given position is valid or not private void insertAtPosition(int value, int position, SinglyLinkedList singlyLinkedList){ ListNode node = new ListNode(value); if (position == 0 || position > singlyLinkedList.length()+1){ System.out.println("Error, Invalid Position"); return; } }
Please *Subscribe* and *Click Bell* 🔔🔔🔔 Icon for More Updates. To get *Data Structures and Algorithms* complete course for free please follow this link - ua-cam.com/play/PL6Zs6LgrJj3tDXv8a_elC6eT_4R5gfX4d.html
Best series for DS & Algo. I am also 10 yrs java exp guy. Was looking for DS & Algo free course over UA-cam with java implementation and found this. Hats Off To You Man...Excellent Work. GOD BLESS YOU :)
Thanks !!!
Are you preparing for an interview?
I see many people learning DSA with C/C++, but I decided to learn it in JAVA for full stack development related opportunities. But the resources are very few for DSA in JAVA😶 Luckily I found this🤞. Thank you so much sir for giving some hope for many people like me...! Lastly, Thanks for spreading this Knowledge instead of selling it🤩👏👏👏. I will definitely share this with many👍
- Samanvitha : )
Thanks for the support !!! Glad you liked it !!!
at 5:47 , couldnt you use a for loop instead of a while loop at line 57?
for(int count = 1; count < position - 1; count++){}
Yes you can !!!
@@itsdineshvaryani i've been binge watching all your videos lately, and theyve been such a massive help. Thanks so much!
Thanks !!!
Thanks !!!
Very well explained! Thank you so much for making DSA this much easy!!
Welcome !!!
You made dsa easy to understand
Thanks
i am watching all your videos. very nicely explained👌
Thanks !!! Please share it with ur friends and colleagues. This will help channel grow and motivate me to add more and more videos.
Thanks a lot Dinesh Varyani. This has helped me a lot.
Glad it helped
Never knew light IDE themes could be so catchy :D
Yes it is !!!
@@itsdineshvaryani You sir, are a legend for still being able to reply to all the comments on your channel. Much love
@@raz0229 No problem ... Its a part of youtube journey !!!
Dinesh Kindly say how could i change the theme of eclipse like the one in this video
Thats not eclipse .... Its intellij idea ...
This will fail in case position specified is larger than the current list size. If list has 4 element and I asked to insert an element at position 8 then it will fail. Corner case needs to be considered
Nice explanation sir
Thanks !!!
@Dinesh Varyani why cant u discuss the time and space complexity for each operations insert,delete etc...
will add those soon
What if the given position is invalid? Should we write an if statement at the beginning of insert ()?
You can provide that edge case ... But its assumed position is valid !!!
You can make the following changes in your code if you want to check if a given position is valid or not
private void insertAtPosition(int value, int position, SinglyLinkedList singlyLinkedList){
ListNode node = new ListNode(value);
if (position == 0 || position > singlyLinkedList.length()+1){
System.out.println("Error, Invalid Position");
return;
}
}
You are amazing sir ❤️
Thanks !!!!
What will happen if we add at certain position like 5 when list is empty
nullpointer exception. Because target 'next' will be empty at one position.
sir notes or ppt dona interiview keliye read karna hai apke easy hai notes plz
Super 🎉
Sir Thank you very much for this but why there is so less likes ?
you share it with ur friends and colleagues on linkedin and facebook as post and you will see magic !!!
I just started learning DSA and I am curious on why your count starts from one and not zero. Any particular reason why?
you can start from 0 ... it doesnt matter ... just make calculations based on 0
@@itsdineshvaryani thanks for responding
@@chinomsojohnson8746 then while runs till (position-2)
Very nice sir
Thanks !!!
public void insert(int position,int data){
ListNode newNode=new ListNode(data);
if(position==1){
newNode.next=head;
head=newNode;
}
else{
ListNode previous=head;
int count = 1;
while(count < position-1);{
previous=previous.next;
count++;
}
ListNode current=previous.next;
previous.next=newNode;
newNode.next=current;
}
}
Exception in thread "main" java.lang.NullPointerException: Cannot read field "next" because "previous" is null
at SinglyLinkedList.insert(SinglyLinkedList.java:40)
You can make the following changes in your code if you want to check if a given position is valid or not
private void insertAtPosition(int value, int position, SinglyLinkedList singlyLinkedList){
ListNode node = new ListNode(value);
if (position == 0 || position > singlyLinkedList.length()+1){
System.out.println("Error, Invalid Position");
return;
}
}
Amazing DSA playlist
You can make the following changes in your code if you want to check if a given position is valid or not
private void insertAtPosition(int value, int position, SinglyLinkedList singlyLinkedList){
ListNode node = new ListNode(value);
if (position == 0 || position > singlyLinkedList.length()+1){
System.out.println("Error, Invalid Position");
return;
}
}
Thanks !!!
Thanks sir
Welcome !!!