Possible Duplicates:
Using arrays or std::vectors in C++, what's the performance gap?
std::vector is so much slower than plain arrays?
memory is vector of 1000 elements array[] is an integer array of 1000 elements
for (iteration = 0; iteration < numiterations; iteration++) {
for (j = 1; j < numints; j++) {
memory[j] += memory[j - 1];
//array[j] += array[j - 1];
}
}
If I compare the time of the for loop after running 100 iterations, time required for accessing is very much small compared to that of vector
why is the case ? because I thought both takes constant and nearly same time ..