The worst-case is O(∞). The best-case is O(n2), because you have to generate n numbers, and for each number generated you have to search a list of length n whether or not the number is already in there.
Jörg W Mittag
- 104.7k
- 24
- 226
- 327