Hi,
I need to implement list based on dynamic arrays (second task is to implement as double linked list). Both tasks are done, but I have problem with time limit on test platform when values are millionths. I suppose that resizing dynamic array is delaying so much. I have implemented common list methods as push_front(), pop_back() ... For example:
void push_front(int x)
{
size++;
int* tab_temp = new int[size];
memcpy(tab_temp + 1, tab, (size - 1) * sizeof(int));
tab_temp[0] = x;
delete [] tab;
tab = tab_temp;
}
I thought about change resizing step from 1 to 10, but I have to ask whether is it allowed. Maybe some advices?