Cosa significa


15

Cosa significa ?logO(1)n

Sono consapevole della notazione big-O, ma questa notazione non ha senso per me. Non riesco a trovare nulla al riguardo, perché non c'è modo che un motore di ricerca lo interpreti correttamente.

Per un po 'di contesto, la frase in cui l'ho trovata recita "[...] chiamiamo una funzione [efficiente] se usa lo spazio O(logn) e al massimo logO(1)n per articolo."


1
Concordo sul fatto che non si dovrebbero scrivere cose del genere, a meno che non si sia molto chiari su cosa significhi (e si dica al lettore cosa sia) e si utilizzino le stesse regole in modo coerente.
Raffaello

1
Sì, si dovrebbe invece scriverlo come (log(n))O(1).

1
@RickyDemer Non è questo il punto che Raphael sta facendo. significa esattamente ( log n ) b l a h . logblahn(logn)blah
David Richerby,

4
@Raphael Questa è la notazione standard nel campo. Chiunque sappia cosa significherebbe.
Yuval Filmus,

1
@YuvalFilmus Penso che la varietà di risposte in disaccordo sia una prova conclusiva che la tua affermazione è falsa e che si dovrebbe effettivamente astenersi dall'utilizzare tale notazione.
Raffaello

Risposte:


16

Devi ignorare per un momento la forte sensazione che la " " sia nel posto sbagliato e proseguire con la definizione a prescindere. f ( n ) = log O ( 1 ) n significa che esistono costanti k e n 0 tali che, per tutti n n 0 , f ( n ) log k 1 n = log kOf(n)=logO(1)nkn0nn0 .f(n)logk1n=logkn

Si noti che significa ( log n ) k . Le funzioni del log del modulo O ( 1 ) n sono spesso chiamate pollogaritmiche e si potrebbe sentire la gente dire " f è polilogo logkn(logn)klogO(1)nf ".n

Noterai che è facile dimostrare che , poiché 2 n k n per tutti n 0 , dove k = 2 . Ci si potrebbe chiedere se 2 log n = log O ( 1 ) n . La risposta è sì poiché, per n abbastanza grande , registro n 2 , quindi 2 log n log 2 n per abbastanza grande 2n=O(n)2nknn0k=22logn=logO(1)nnlogn22lognlog2n .n

In una nota correlata, vedrai spesso polinomi scritti come nO(1): same idea.


This is not supported by the common placeholder convention.
Raphael

I retract my comment: you write in all the important places, which is sufficient.
Raphael

@Raphael OK. Non avevo ancora avuto il tempo di verificarlo, ma la mia sensazione era che potresti ordinare quantificatori in modo diverso da come sono io. In realtà non sono sicuro che stiamo definendo la stessa classe di funzioni.
David Richerby,

Penso che tu stia definendo il mio (2), e Tom definisce . cR>0{logcn}
Raffaello

9

Si tratta di un abuso della notazione che può essere interpretato dalla convenzione del segnaposto generalmente accettata : ogni volta che trovi un termine Landau , sostituiscilo (nella tua mente o sulla carta) con una funzione arbitraria g OO(f) .gO(f)

Quindi se lo trovi

f(n)=logO(1)n

devi leggere

per alcuni g O ( 1 ) .f(n)=logg(n)ngO(1).(1)

Note the difference from saying "log to the power of some constant": g=n1/n is a distinct possibility.

Warning: The author may be employing even more abuse of notation and want you to read

f(n)O(logg(n)n) for some gO(1).(2)

Note the difference between (1) and (2); while it works out to define the same set of positive-valued functions here, this does not always work. Do not move O around in expressions without care!


3
I think what makes it tick is that xlogx(n) is monotonic and sufficiently surjective for each fixed n. Monotonic makes the position of the O equivalent and gives you (2) ⇒ (1); going the other way requires g to exist which could fail if f(n) is outside the range of the function. If you want to point out that moving O around is dangerous and doesn't cover “wild” functions, fine, but in this specific case it's ok for the kind of functions that represent costs.
Gilles 'SO- stop being evil'

@Gilles I weakened the statement to a general warning.
Raphael

1
This answer has been heavily edited, and now I am confused: do you now claim that (1) and (2) are effectively the same?
Oebele

@Oebele As far as I can tell, they are not in general, but here.
Raphael

But, something like 3log2n does not match (1) but does match (2) right? or am I just being silly now?
Oebele

6

It means that the function grows at most as log to the power of some constant, i.e. log2(n) or log5(n) or log99999(n)...


This can be used when the function growth is known to be bounded by some constant power of the log, but the particular constant is unknown or left unspecified.
Yves Daoust

This is not supported by the common placeholder convention.
Raphael

2

"At most logO(1)n" means that there is a constant c such that what is being measured is O(logcn).

In a more general context, f(n)logO(1)n is equivalent to the statement that there exists (possibly negative) constants a and b such that f(n)O(logan) and f(n)Ω(logbn).

It is easy to overlook the Ω(logbn) lower bound. In a setting where that would matter (which would be very uncommon if you're exclusively interested in studying asymptotic growth), you shouldn't have complete confidence that the author actually meant the lower bound, and would have to rely on the context to make sure.


The literal meaning of the notation logO(1)n is doing arithmetic on the family of functions, resulting in the family of all functions logg(n)n, where g(n)O(1). This works in pretty much the same as how multiplying O(g(n)) by h(n) results in O(g(n)h(n)), except that you get a result that isn't expressed so simply.


Since the details of the lower bound are in probably unfamiliar territory, it's worth looking at some counterexamples. Recall that any g(n)O(1) is bounded in magnitude; that there is a constant c such that for all sufficiently large n, |g(n)|<c.

When looking at asymptotic growth, usually only the upper bound g(n)<c matters, since, e.g., you already know the function is positive. However, in full generality you have to pay attention to the lower bound g(n)>c.

This means, contrary to more typical uses of big-oh notation, functions that decrease too rapidly can fail to be in logO(1)n; for example,

1n=log(logn)/(loglogn)nlogO(1)n
because
lognloglognO(1)
The exponent here grows in magnitude too rapidly to be bounded by O(1).

A counterexample of a somewhat different sort is that 1logO(1)n.


Can't I just take b=0 and make your claimed lower bound go away?
David Richerby

1
@DavidRicherby No, b=0 still says that f is bounded below. Hurkyl: why isn't f(n)=1/n in logO(1)n?
Gilles 'SO- stop being evil'

@Gilles: More content added!

@Gilles OK, sure, it's bounded below by 1. Which is no bound at all for "most" applications of Landau notation in CS.
David Richerby

1) Your "move around O" rule does not always work, and I don't think "at most" usually has that meaning; it's just redundant. 2) Never does O imply a lower bound. That's when you use Θ. 3) If and how negative functions are dealt with by a given definition of O (even without abuse of notation) is not universally clear. Most definitions (in analysis of algorithms) exclude them. You seem to assume a definition that bounds the absolute value, which is fine.
Raphael
Utilizzando il nostro sito, riconosci di aver letto e compreso le nostre Informativa sui cookie e Informativa sulla privacy.
Licensed under cc by-sa 3.0 with attribution required.