-
Notifications
You must be signed in to change notification settings - Fork 484
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Floyd's Cycle Detection Algorithm #155
Conversation
For contribution and more guidelines i would recommend you to go through this Hey @janhavikale06 , make sure your Pull Request is descriptive and complete the checklist . Let me show you how to check the check list , there should be no space inside brackets like [x]
|
Hey@
@janhavikale06 |
Kindly add it to the right location this path is not expected |
|
It's because you are just using one particular test case , it's not generalised, run it for 1->2->3->4->5->null, create this linked list, any list of odd length having no cycle will give you error |
curr->next->next->next = new_node(4); | ||
curr->next->next->next->next = new_node(5); | ||
curr->next->next->next->next->next = new_node(6); | ||
curr->next->next->next->next->next->next = loop_node; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@janhavikale06 Don't you think it would be better to write the above line of code in a generalized way?
Rather than writing so many next's per instruction, just move the curr pointer ahead.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes it would be much better , I'll try do that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @n4i9kita , can please give me a hint to create a linked list in generalized way which has loop node in it? If I'm asking user to give me nodes then how can I'll create a loop node in it?
I'm finding it difficult to do , can you please help me?
@janhavikale06 Don't you think it would be better to write the above line of code in a generalized way? Rather than writing so many next's per instruction, just move the curr pointer ahead.
Hey @n4i9kita , can please give me a hint to create a linked list in generalized way which has loop node in it? If I'm asking user to give me nodes then how can I'll create a loop node in it?
I'm finding it difficult to do , can you please help me?
@@ -0,0 +1,82 @@ | |||
/*Floyd's Cycle Detection Algorithm |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As the explanation of the algorithm will be provided in the readme section, it seems redundant here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay , got it.
node *new_node(int data) | ||
{ | ||
node *curr ; | ||
curr = (node*)malloc(sizeof(node)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't it be better to use new
operator to allocate memory on heap, rather than malloc
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Latest update, candidate didn’t-respond to previous proposed changes.
Sorry I was having some personal issues that's why I didn't see all this responses. I will do all changes as soon as possible , sorry for my late response. |
Related Issue
#59
Proposed Changes
Added Floyd's Cycle Detection Algorithm
Additional Info
Checklist
Output Screenshots