Insert them into a pseudo-random order, like here:
#include <stdio.h> int array[] = {1,2,3,4,5,6,7,8,9,10}; #define COUNT 10 #define STEP 7 /* must be relatively prime wrt COUNT */ #define START 5 /* not important */ int main(void) { unsigned idx; idx=START; while(1) { printf("[%u] = %u\n", idx, array[idx] ); // do_insert(array[idx] ); idx = (idx + STEP ) % COUNT; if (idx == START) break; } return 0; }
source share