I am trying to compare sort methods for my algorithms class and need to write all of the code for each method. My professor wants us to copy a randomly generated array and make 8 copies of it for each of the sorting methods. I'm at a loss as how to do this since the array can be up to 1,000,0000 numbers.

Can someone assist me?
Thanks!!

Instead of making 8 copies of that huge array I'd make just two, say array A and B. pass array A to a sort method, after sorted copy B to A and pass A to the second method. Do this for each sort algorithm. It'll save a whole lot of memory.

How to copy arrays depends on the kind of array you want. If c++ vector then its a simple assignment.

vector<int> A;
vector<int> B;
B = A;

if its a C-style array

int A[1000000];
int B[1000000];
memcpy(B, A, sizeof(A));
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.