Const tracing array in random order

I want to...

std::random_shuffle(begin(a), end(a));
for (auto x : a) {
  use(x);
}

      

... but a

- const

. Is the possibility of random ordering possible in O (n) time and O (1) space?

+3
c ++ algorithm


source to share


No one has answered this question yet

See similar questions:

20
Create arbitrary permutation 1..N in constant space

or similar:

23498
Why is processing a sorted array faster than processing an unsorted array?
3714
How to check if an array contains a value in JavaScript?
1994
What are the basic rules and idioms for operator overloading?
1518
Image processing: improvement of the algorithm for the recognition of "Coca-Cola Can"
1250
Replacing 32-bit loop counter with 64-bit values ​​leads to crazy performance deviations
1239
What is the difference between const int *, const int * const and int const *?
838
How can I convert std :: string to const char * or char *?
629
How do I create a URL shortener?
234
Get a random number centered on the center
115
Lambda capture as const reference?



All Articles
Loading...
X
Show
Funny
Dev
Pics