It's implementation-defined, each library author is free to implement it as they see fit. However, they are normally based on linear congruential generators, which are somewhat limited. the POSIX standard gives an example implementation:
static unsigned long next = 1;
/* RAND_MAX assumed to be 32767 */
int myrand(void) {
next = next * 1103515245 + 12345;
return((unsigned)(next/65536) % 32768);
}
void mysrand(unsigned seed) {
next = seed;
}
I'm not sure what you mean by "time complexity" here; "time complexity" normally refers to how the run-time varies with respect to n
(where n
is the size of the input or something).