How should I know if a linked account has included a cycle?

Asked By 0 points N/A Posted on -
qa-featured

How should I know if a linked account has included a cycle in it and, at what node the cycle starts? And how will you switch the double contact account?

SHARE
Answered By 55 points N/A #107100

How should I know if a linked account has included a cycle?

qa-featured

You can try the following things in order to see if a linked account has included a cycle or not in it.

 Suppose that if a linked account has a cycle in it then

  • The malformed linked account will have no end. Means that no last node will have next node address.
  • The malformed linked account might contain two more links to some other nodes.
  • Iterating through the malformed linked account will surely yield all the nodes in the loop for as multiple amount of time.

What is a malformed linked account? A malformed linked account having a loop in it cause the  iteration over the list to fail because the iterating loop will never be able to reach the end of the list. Therefore, it is very efficient way to be able to detect that a linked account is malformed before trying an iteration solution or applying a loop on it.

You can also see Floyd's Cycle Finding Algorithm for a complete detailed answer.

Related Questions