Why increase pointer by two while finding loop in linked list, why not 3,4,5?

From a correctness perspective, there is no reason that you need to use the number two. Any choice of step size will work (except for one, of course). However, choosing a step of size two maximizes efficiency. To see this, let’s take a look at why Floyd’s algorithm works in the first place. The idea … Read more

How does finding a cycle start node in a cycle linked list work?

Let me try to clarify the cycle detection algorithm that is provided at Wikipedia – Tortoise_and_hare in my own words. How it works Let’s have a tortoise and a hare (name of the pointers) pointing to the beginning of the list with a cycle, as in the diagram above. Let’s hypothesize that if we move … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)