Posted on 2004-04-14
i need a little bit of help here - i'll try to explain it as best as i can.
I'm creating a program that will time the length of time taken to execute various sorting algorithms. I'm using the System.currentTimeMillis() before and after tha algorithm to time it. However, since most of the algorithms run really fast, i have to execute the loop many times getting the time at the start and at the end and then getting the average. However, I need to reset the values of the array back to the unsorted values each time. When i use something like newArray = oldArray, the values in oldArray automatically get replaced with the sorted values and i end up sorting the already sorted values. Is there any way i can copy the values of the array without it changing the values of the original. I cant use a for loop and do the values one at a time because this would then affect the running time of the algorithm that i am trying to time.
any help would be much appreciated.