dimanche 22 décembre 2019

std::rand and randomized quick sort algorithm [duplicate]

This question already has an answer here:

I am trying to implement a quick sort algorithm in c++ where the pivot used for the partitioning is randomly selected. Currently, I am using std::rand() to randomly select the pivot.

However, I have read that the header contains more varied and useful algorithms for randomly generating numbers.

I am unsure if I should just use std::rand() or if I should use one of the random number generators in the header. I feel like the header seems to be a bit more than I need because I do not need any special algorithm to generate random numbers.

My question is, am I wrong in this assessment and, if so, which random number engine from the header should I use?




Aucun commentaire:

Enregistrer un commentaire