Manahil
Manahil

Reputation: 265

Recursive MergeSort using LinkedList

Please help me understand how s and f are getting random values and code is behaving this way.

Following is my code for MergeSort : enter image description here

Problem

My linked list orginally have following values in the following order: 6 2 53 1 3 5 30 100

When I cout the values of cut, f ,s it gives following:

enter image description here

and after last value of s, it says stopped working as if a segmentation fault has occured.

Question: I do not understand that how s and f are getting random values and code is behaving this way.

Upvotes: 1

Views: 207

Answers (1)

Pooya
Pooya

Reputation: 6136

Probably you need the following line at the end of your else block:

return merged;

Upvotes: 2

Related Questions