Calculating Search Times
Posted on 2003-03-11
Ok, I'm going crazy!
I have a basic program to make. It is suppose to calculate the average time it takes to do a search.
My code looks like this:
//sequential search function
//x = search value
clock_t start, end;
start = clock();
for (i =0; i<n && CurrentArray[i] !=x; i++)
exit (.1); //ERROR! x not found!
end = clock();
I preform this search about numerous times, with randomly chosen x values .
ok so the problem I have is that no matter how large my array is, the return time is ALWAYS zero, IF I allow the function to run on it's on. However if I debug it, executing the code line by line I am able to get none zero times.
I have already recieved a 60 for this project, but have midterms soon!