Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6881157
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:04:19+00:00 2026-05-27T05:04:19+00:00

In the interview question, Implement an algorithm which detects for presence of the loop..

  • 0

In the interview question, “Implement an algorithm which detects for presence of the loop.”. For example, the linked list has a loop, like:

0--->1---->2---->3---->4---->5---->6
                 ▲                 |
                 |                 ▼
                11<—-22<—-12<—-9<—-8

Using Floyd’s cycle detection, this problem can be solved by using a fast & slow pointer. So should I try comparing

a. Link’s node values, i.e.

if (fast.data == slow.data) 
    break;

where fast and slow are of type Link

class Link
{
    int IData {get; set;}
    Link Next {get; set;}
}

OR

b. Are they pointing to same reference, i.e. if (fast == slow)

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:04:19+00:00Added an answer on May 27, 2026 at 5:04 am

    You should only be comparing the nodes themselves. After all, it’s reasonable to have a linked list with repeated data in, without it actually having a cycle.

    I would call them nodes rather than links too. A link is simply the reference from one node to the next or previous one – in particular, there’s no data associated with a link, only with a node.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Linked list interview question This is an interview question for which I
I was asked this question in an interview. I implemented an algorithm using sieve
Interview question: Design a data structure which has the following features push the data
How to implement singleton without using static/global variable? Possible? This is an interview question...
I was browsing Scott Hanselman's Developer Interview question list , and ran across this
It was an interview question. I was asked to implement the StringBuffer append function.
As an exercise (read:interview question) in index optimisation, I need a query which is
Another interview question which was expecting a true / false answer and I wasn't
Interview question: For example, I have 3 classes A,B & C. I navigate from
This is an interview question. How do you implement a read/write mutex? There will

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.