How to find middle node in a Singly Linked List in Java? | Data Structures and Algorithms
Вставка
- Опубліковано 19 вер 2024
- ►Full DSA Course - • Data Structures and Al...
►Follow me on Instagram - bit.ly/intrvwk...
►Follow me on LinkedIn - bit.ly/fllwlkdn
►Enroll in the complete course: bit.ly/3W4qthg
►Source Code - github.com/din...
►Download DSA Animation Slides - techready.in/c...
►Click here to subscribe - www.youtube.co...
Watch all my playlist here:
►Data Structures and Algorithms Course playlist: • Data Structures and Al...
►Mastering JUnit 5 - www.youtube.co...
►Mastering Mockito 3 - • Mockito 3 Tutorials
►Analysis of Algorithms - • Analysis of Algorithms
►Linked List Data Structures - • Linked List Data Struc...
►Array Data Structures - • Playlist
►Stack Data Structure - • Stack Data Structure
►Queue Data Structure - • Queue Data Structure
►Binary Tree Data Structure - • Binary Tree Data Struc...
►Graph Data Structure - • Graph Data Structure
►Binary Heap Data Structure - • Binary Heap Data Struc...
►Trie Data Structure - • Trie Data Structure
►Dynamic Programming Algorithms - • Dynamic Programming Al...
►Hashing Data Structures - • Hashing Data Structures
►Sorting and Searching - • Sorting and Searching
►String Algorithms - • String Algorithms
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
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 - 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 !!!
It the list contains only one node then. It will throw null pointer exception sir. Other than that Algorithm is really good. I love it, slow pointer works at 1X speed and fast pointer works as 2X speed. Once 2x traversed at end 1X will be in middle at the time. Superb!!!
thanks !!!
You also have to tell the middle node for number of nodes if there are 1 or 2.
(1) if there is only one node in List then it will return the same node as middle node.
(2) if there are 2 nodes in List then it will return the second node as middle node.
Great explanation. Thank you!
Welcome
explanationation is extremly nunbelievable wow ......well explained
Thanks !!!
Awesome explanation. Thanks
Great explanation sir!
The first ever video that i have commented!!
Thank you!!!
Welcome !!!
Thanks for this information..
Welcome !!!
This Algorithm is good..
For finding the middle node..
good explaination
This code is absolutely right for 4 and 5 nodes
But what if we want more than 20 nodes
I think it will fail to give us middle node
Please reply
It will give respective middle node !!!
The linked list you see in slide is for explaining how code will work on it. It will work on any number of nodes.
@@itsdineshvaryani yeah it worked .
thanks a lot
Lot of learning sir, but which software you use and recommend ?
Software as in IDE ???
Sir Your content is awesome!!! but sir just one thing can you please show the implementation in separate programs ...!
you mean in separate video ???
@@itsdineshvaryani No sir it feels little confusing when insertion deletion and all the etc etc code written in one single program. Just commenting it out makes it conjusted!!!!
@@vishnukar4520 those are individual methods that isn't a problem.
consider we have 13 node. then middle of node will be 7th node, so in that case above logic will fail right ?
Then count the first linked list length the u can find the middle of then no matters it's odd or even length elements
Yes its one way !!!
thank you sir!!!
Most welcome!
Sir this is 57 lecture and i comple in 3 days ..💪💪
The explanation is very good but for some reason, when trying to run the method, a java.lang.NullPointerException is thrown.
I have added source code github link in description of video. Please check !!!
Insertion logic little bit modification required otherwise u will get null pointer exception 😂
in case of even suppose x and x+1 is the middle node,but on execution always x+1 is my output..how to deal with it.
hello sir ,
ListNode middle = s11.middleone();
what the above precedure is called? is it dynamic binding.....kindly explain sir plzzzzzzzzzzzzzzz
@vivek... i feel you first understand basic syntax and terminologies for Java ... you first learn those and after that watch this series !!!
nice video !!
Thanks !!!
good
Nice
Thanks
hey sir why you write return type as Listnode??
coz u return middle node which of ListNode type
Find length.
If length is odd then middle node=(length+1)/2,
If length is even then middle node=(length)/2 and (length)/2 +1..
Break the loop once you find the middle node.I think O(n) will be approx 1.5 times than the above code..
if the list contain 2 elements then it will gives an error.
Hello Sir can u help write code for taking out permutation in single step.
Didnt get u !!! You want any specific video on permutation ???
@@itsdineshvaryani in my paytm interview I have explained him with recursive. But he want in single step
@@tannubajpai4782 can u tell me exact question he asked ??? Was it related to this video only ...
@@itsdineshvaryani no it's not related to video. U explaination awsm. I thought u can help me.
Question: to find permutation of string in single step?
Does single step means single line ... If yes please check this link ...stackoverflow.com/questions/56551982/one-line-java-string-random-permutation