anyone has an idea how can i do this?
thank
It smells like a domestic problem, but I'll throw you a bone ...
http://eli.thegreenplace.net/2008/08/23/initializing-an-array-in-constant-time/
If you need to do something for each element in a set of elements n, you cannot do it better than O ( n) performance .
n
" N , N", . , , .
, . ( hashmap, , ), .
, . ++ :
int foo[1000] = {0};
0
, O (n)
, , . , n, O(n); , , , .
O(n)
; , O(n), O(n), O(1).
O(1)
. reset, , , . , , .
O (1), Amortized Analysis . ( ).
O (1). .
. . , O (n * 1/k), k - . O (n), .