Getting segmentation fault on running the program.
Link to the code : https://ide.codingblocks.com/s/259038
Merge Sort Not working in Linked List
error is due to node
*mid_point(node *head{} this function
try split this linked list
1->2
it will never split this
so change you have to do is
node *fast = head->next;
node *slow = head;
@asaurabh_26 Can you tell me why mid_point function is not working in case I want to find mid point of even linked list. Even linked list has two mid points if fast = head, I should get the first mid point and in case of fast = head->next I should get the second mid point !But this is not working as expected?
as explained above
using your mid_point function
you cann’t split the list of 2 nos
you will find mid as second element every time
hence you are stuck in a cycle
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.