How to detect a loop in a Singly Linked List in Java? (Animation)

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
Рекомендации по теме
Комментарии
Автор

This code is pretty similar to finding the middle node of a singly linked list just that the 'if condition' that checks whether both 'fast' as well as the 'slow' pointers points to the same node thus detecting the presence of a 'loop' is an 'extra'. Thanks 👍👍

aakashggujju
Автор

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
Автор

your videos are too good
finally im understanding dsa

deadeye
Автор

Sir I just want to thank you for making this playlist, u r awesome sir, hope you are happy wherever you are🤗🤗🤗

toofangaming
Автор

Same as two pointer reverse linked list approaches one thing is extra lastly we compared both the pointers equal or not then got the linked list is looping nice work 🙏

pratapjavasingh
Автор

we can put if condition one more time before increasing slow pointer will reduce the time complexity

souravsaini
Автор

Thank you so much Sir for this playlist.. Really helpful and all concepts have been thoroughly covered..

siriusjunior
Автор

will it detect cycle if a cycle is present between 1 and 6 th node

hariharan
Автор

if space is not an issue then it that case we can use a hashmap to store all the visited nodes and if some node is pointing to a node which is already visited then there is a loop.
Please feel free to correct me.

ManishKumar-qxkh
Автор

what if the last sixth node next is the second node?

LuizFelipe-owgf
Автор

How does this algorithm guarantees that slowPtr and fastPtr would coincide at some point, what if the loop is way bigger, would the algorithm still holds?

ananthukkumar
Автор

How does this help us in writing Java code? Is this just to understand how a hashmap will be stored and maintained by Java in the memory??

udhayhakarthik
visit shbcf.ru