I am using a merge sort algorithm to sort a linked list
void node::merge_sort()
{
if (head == NULL || head->next == NULL)
{
return;
}
node *p = new node;
node *q = new node;
this->divide(&p, &q);
p->merge_sort();
q->merge_sort();
this=merge_lists(p, q);
}
but I have to change the object inside this method due to which I typed this=merge_lists(p,q)
. But this is giving an error saying nolvalue. Is there any alternative way?
The divide function is used to divide the list into two parts and store them in p and q.