int index = 0;
do{
index = v1[index];
}while(index != 0)
int index = 0;
do{
index = v2[index];
}while(index != 0)
The question is, would the first while-loop with v1 perform best in time or are there no difference between v1 and v2?
I have tried to benchmarked v1 and v2 with a length of 100.000, but it seems there are no difference. As my point of view v1 should give the lowest computation time because it should give a better cache hit than v2, but I'm not sure it is right.
I am asking because I have an unsorted array like v2. I'm wonder if it could be a good idea to sort the array according to the indexes.
I know this is a philosophical question, but maybe you know where to find information about cache performance related to this problem,
I am a new member , I did not know how can I ask my question ! for this reason send reply to your . my question is about store one char array with 2 for loop to one char 2D array . I write the code and did not give any error but I could not see the result .