79686426

Date: 2025-07-01 17:35:15
Score: 2.5
Natty:
Report link

TLDR: The operation described is not an algorithm so big-O does not apply

What is the big O of the algorithm below?

It is not an algorithm to begin with because the operation (in the lack of a better word) you described does not fit the standard definition of what constitutes an algorithm. If it is not an algorithm, you probably should not describe it using big O notation.

As pointed out in the previous answer, the use of a PRNG is probabilistically distributed, so the time bounds would converge to a finite set of steps eventually. The rest of my answer will now assume a truly random number generating function as part of your "algorithm".

What is and isn't an algorithm?

Knuth describes an algorithm in TAOCP [1, pp. 4-7] as a "finite set of rules that gives a sequence of operations for solving a specific type of problem", highlighting the characteristics of finiteness, definiteness, input, output, effectiveness.

For concision, your described operation does not:

Moreover, the lack of finiteness prompting this operation to potentially run without ever finding a 5 digit number not in the DB perfectly classifies it as an undecidable problem.

Undecidable problems are not algorithms

Recall that decidability means whether or not a decision problem can be correctly solved if there exists an effective method (finite time deterministic procedure) for solving it [2].

For same reason and akin to the Halting problem [3], your operation is undecidable because it is impossible to construct an algorithm that always correctly determines [see 4] a new 5 digit random number effectively. The operation described is merely a problem statement, and not an algorithm because it still needs an algorithm to correctly and effectively solve it.

Analysis of undecidable problems

Reasons:
  • RegEx Blacklisted phrase (2): even I am
  • Long answer (-1):
  • No code block (0.5):
  • Contains question mark (0.5):
  • Low reputation (0.5):
Posted by: M.A.