Cycle detection and removal

whats wrong in this code

initially both large and small are head so if condition holds true but while is false
come out and set large->next=NULL(means head->next=NULL) every time

correct way to do it is using flod’s algorithm

Code

1 Like