Insert a node in a Singly Linked List at a given position (Implementation)

preview_player
Показать описание

Watch all my playlist here:

Want to land a software engineering job in the IT industry? This course - 'Visualizing Data Structures and Algorithms' is here to help. The course walks you through multiple Java algorithms, data structures problems, and their solutions with step by step visualizations, so that you are actually learning instead of blindly memorizing solutions.

The course covers in and outs of Data Structures and Algorithms in Java. Java is used as the programming language in the course. Students familiar with Javascript, Python, C#, C++, C, etc will also get to learn concepts without any difficulty. The implementation of various Algorithms and Data Structures have been demonstrated and implemented through animated slides. It covers many interview room questions on Algorithms and Data Structures. The questions and solutions are demonstrated by -

1. Animated slide. (To make visualization of algorithms faster)
2. Coding algorithm on IDE.

The course covers topics such as -
0. Algorithm Analysis
1. Arrays
2. Matrix
3. Singly Linked List
4. Doubly Linked List
5. Circular Singly Linked List
6. Stacks
7. Queues
8. Binary Tree
9. Binary Search Tree
10. Graphs
11. Priority Queues and Heaps
12. Recursion
13. Searching
14. Sorting
15. Strings
16. Trie Data Structure
17. Dynamic Programming
and many more ...

#dsa #algorithms #coding
Рекомендации по теме
Комментарии
Автор

Best series for DS & Algo. I am also 10 yrs java exp guy. Was looking for DS & Algo free course over YouTube with java implementation and found this. Hats Off To You Man...Excellent Work. GOD BLESS YOU :)

shubhamagarwal
Автор

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 : )

FashionTales
Автор

Very well explained! Thank you so much for making DSA this much easy!!

kashifsiddiqui
Автор

Thanks a lot Dinesh Varyani. This has helped me a lot.

dineshr
Автор

i am watching all your videos. very nicely explained👌

nirmesh
Автор

Never knew light IDE themes could be so catchy :D

raz
Автор

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++){}

hobojoesnr.
Автор

Sir Thank you very much for this but why there is so less likes ?

pushkarkumaryadav
Автор

@Dinesh Varyani why cant u discuss the time and space complexity for each operations insert, delete etc...

poojithakumaran
Автор

What if the given position is invalid? Should we write an if statement at the beginning of insert ()?

sambeetrath
Автор

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 >
System.out.println("Error, Invalid Position");
return;
}
}

karentechnologies
Автор

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" Cannot read field "next" because "previous" is null
at

nishantpatill
Автор

What will happen if we add at certain position like 5 when list is empty

abhishekpatel
Автор

I just started learning DSA and I am curious on why your count starts from one and not zero. Any particular reason why?

chinomsojohnson
Автор

sir notes or ppt dona interiview keliye read karna hai apke easy hai notes plz

mr.kdrama.o