I have several text files I have code that reads through the

I have several text files. I have code that reads through them and inserts each line in linked list. Then I sort the linked list using merge sort.

This works fine for smaller text files but it generates a stack overflow error for a very large file.

Solution

First of all you are reading everything into a linked list which will be stored on stack in main memory. Then using merge sort is always costly as it adds extra memory usage because of the way it works by dividing and adding partial parts. Because of all these you are facing this issue. Please try using some other sort, it should not fail.

I have several text files. I have code that reads through them and inserts each line in linked list. Then I sort the linked list using merge sort. This works fi

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site