Merge Sort and remove Cycle in SLL


plz check the merge sort1 and remove cycle2 funtion as its not disp anything,
plz check the functions and revert the changes

Hello @akb.tech17,

  1. For merge sort problem i have done very basic corrections inside the mergeSort().
    Rest all seems correct.

  2. Both of your detectCycle() and removeCycle() functions would not work.
    Reason:
    The linked list you are creating is a linear linked with no actual cycles in it.
    Solution:

  3. either detect the node from where the elements start repeating and cut the liked list there.

  4. You can create a loop while inserting elements in your linked list and then apply the logic of two pointers to detect and remove the loop.
    You can refer to this code i have corrected earlier:
    https://ide.codingblocks.com/s/161841 1

I have corrected your code for merge sort:

Hope, this would help.
Give a like if you are satisfied.

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.