Reputation: 1
I have been working on a program that compares the running times of different sorting algorithms in C++ (so far I've done heap sort,bubble sort, insertion sort and selections sort). To calculate the times I'm using arrays of different sizes i.e. 10000, 100000, 500000, 1000000 and 10000000.
When I run it, everything runs fine until I start testing the larger arrays. For the first 3 arrays I get the expected results but then the program keeps crashing when I run the last 2. So my question is, if the problem is the code wouldn't they all crash? could it be a memory management problem? any help or ideas on what could be wrong will be greatly appreciated.
This http://pastebin.com/HCakminT is my code for the driver class which calls the others, in this particular example the heap sort and bubble sort.
Thanks :)
Upvotes: 0
Views: 198
Reputation: 179991
Without seeing the program, it's hard to predict exactly what's happening. But the first question is simple. There are many ways in which your program could be wrong, and some of them would cause a crash only with 1.000.000 elements or more. For instance, if you had hardcoded a memory allocation of 999.999 elements, you would not see a crash with 500.000 elements.
Upvotes: 1