HiveBrain v1.2.0
Get Started
← Back to all entries
patternMinor

Do Oracles run in O(1) or O(n) time?

Submitted by: @import:stackexchange-cs··
0
Viewed 0 times
oraclestimerun

Problem

The common understanding of what oracle does is that it answers a question after a single operation. So at first glance, it runs in $O(1)$. But, doesn't it need to actually read the input? Wouldn't this take at least $n$ steps? If so then wouldn't an oracle run in $O(n)$?

Solution

The oracle runs in a single step. Yes, it would take an ordinary Turing machine some number of steps to read the input but an oracle isn't an ordinary Turing machine – that's almost the whole point of using them. Also, the time taken for the oracle to read its input is essentially accounted for by the time it took the calling machine to write that input. So, oracles return in $O(1)$ steps. More precisely, they return in exactly one step.

Also, it's not quite clear what you mean by "$O(n)$ steps". $n$ usually denotes the length of the input we're trying to compute on, which would be the input to the calling machine, not the oracle. The input to the oracle could be arbitrarily long. For example, you could have a machine that takes an input $x$ and calls an oracle to ask if the string consisting of $2^{2^{2^{|x|}}}$ zeroes is in the language decided by the oracle. Moral of the tale: don't write functions of $n$ without saying what $n$ is.

Context

StackExchange Computer Science Q#60183, answer score: 3

Revisions (0)

No revisions yet.