Docsity
Docsity

Prepara tus exámenes
Prepara tus exámenes

Prepara tus exámenes y mejora tus resultados gracias a la gran cantidad de recursos disponibles en Docsity


Consigue puntos base para descargar
Consigue puntos base para descargar

Gana puntos ayudando a otros estudiantes o consíguelos activando un Plan Premium


Orientación Universidad
Orientación Universidad


brassard tema 2, Apuntes de Representación de Datos y Diseño de Algoritmos

Asignatura: Analisis y diseño de algoritmos I, Profesor: , Carrera: I. T. Infor. Sistemas, Universidad: UCA

Tipo: Apuntes

Antes del 2010

Subido el 22/12/2008

josellle
josellle 🇪🇸

4.4

(60)

148 documentos

1 / 5

Toggle sidebar

Esta página no es visible en la vista previa

¡No te pierdas las partes importantes!

bg1
CRUSADE FOR A BETTER NOTATIO
N
Gilles Braesard
t
Departement d'informatique et de recherche operationnel
e
Universite de Montreal, C
.P
. 6128, Slice "A"
,
Montreal (Quebec)
Canada
H3C 3l
7
ABSTRACT
'
In
a
well-known SIGACT/NEWS
paper, Knuth
sets forth
the asymptoti
c
notation by which we all now live [K76]. He closes his discussion with: "I propos
e
that members of SIGACT (
.
.
.) adopt the
0,
fl
and
a
notations
as defined above
,
unless a better alternative can be found reasonably soon"
. Although one ca
n
hardly consider
nearly a
full decade later as
being "reasonably soon
"
,
I would lik
e
to share with
you
my
thoughts on
the subject
.
1
. In Praise of Set Theor
y
In the second edition of his Volume 1 [K731, Knuth mentions that "formulas which involv
e
the
0(f
(n))-notation may be regarded as sets of functions of n". In a SIGACT/NEWS pape
r
[K76], he explains why
defining
asymptotic notation in terms of acts is an improvement over th
e
definition in the first printing of his Volume 1 [K68]
. He then goes on to say
: "The
phenomeno
n
of
one-way equalities
)
arises in this connection, (
. .
.)
. The
equal sign here
really means C (se
t
inclusion
)
2
(
.
.
.)
. My
(Knuth
'
s
)
feeling is that we
should
continue to use
one-way
equalities
togethe
r
with 0-notations, since it has been common practice of thousands of mathematicians for so man
y
years now, and since we
understand
the meaning of our existing notation sufficiently well"
.
I strongly disagree with the above statement
. I do not believe that a bad, irrational an
d
confusing notation should be encouraged when a better
and
more natural alternative is available
.
To give an
analogy
outside the realm of computer science
: should not the United States switch t
o
the metric system, even
though
the British system is common practice of hundreds
of millions
o
f
Americans and does not perform all that badly
?
What is the
alternative?
Once the asymptotic notation is defined in terms of sets, it is onl
y
natural to manipulate it using set notation
. If "the equal sign really means set inclusion", wh
y
not
use
set inclusion? I wish to emphasise that this reaches far beyond a purist
'
s aestheti
c
preferences
. Indeed, it allows any number of big Oh's to be used in arbitrary set theoreti
c
formulae, with no fear of confusion or ambiguous meaning
. It even allows tree mixing of 0 wit
h
fl and 8, as well as any set theoretic and arithmetic symbols appropriate to precisely conve
y
one's intended meaning
. Why refuse this powerful tool? As two simple examples, one can write
:
9(f
(n )) = O(f (n))(1fl(f (
n
)
)
(notice that the
equal sign
above
really
stands for standard set equality)
,
t This letter was written while the author was at the University of California at Berkeley
; it was supported i
n
parts by NSF grant 21828
.
t
The equal sign conventionally used in conjunction with asymptotic notation is
not commutative
; example
s
of one-way equalities are
:
5n'+3—O(n')
and
0(n)O(n°)
.
One should
never
write them the other wa
y
around such as
0(n')
.=511
2
+3
or
0(n'')I=O(n)
.
2
The current author would add: "or E (set membership), in most cases"
.
17
.1-60
pf3
pf4
pf5

Vista previa parcial del texto

¡Descarga brassard tema 2 y más Apuntes en PDF de Representación de Datos y Diseño de Algoritmos solo en Docsity!

CRUSADE FOR A BETTER NOTATIO N

Gilles Braesardt Departement d'informatique et de recherche operationnele Universite de Montreal, C .P. 6128, Slice "A" , Montreal (Quebec) Canada^ H3C 3l

ABSTRACT'

In a well-known SIGACT/NEWS paper, Knuth sets forth^ the asymptoti c notation by which we all now live [K76]. He closes his discussion with : "I propose

that members of SIGACT (.. .) adopt the 0, fl and a notations as defined above ,

unless a better alternative can be found reasonably soon". Although one can hardly consider nearly a full decade later as being "reasonably soon " , I would lik e to share with you my thoughts on the subject.

1. In Praise of Set Theory In the second edition of his Volume 1 [K731, Knuth mentions that "formulas which involv e the 0(f (n))-notation may be regarded as sets of functions of n". In a SIGACT/NEWS pape r [K76], he explains why defining asymptotic notation in terms of acts is an improvement over th e definition in the first printing of his Volume 1 [K68]. He then goes on to say : "The phenomenon of one-way equalities ) arises in this connection, (.. .). The equal sign here really means C (se t inclusion ) 2 (.. .). My (Knuth 's ) feeling is that we should continue to use one-way^ equalities togethe r with 0-notations, since it has been common practice of thousands of mathematicians for so man y years now, and since we understand the meaning of our existing notation sufficiently well".

I strongly disagree with the above statement. I do not believe that a bad, irrational an d confusing notation should be encouraged when a better and more natural alternative is available. To give an analogy outside the realm of computer science : should not the United States switch t o the metric system, even though the British system is common practice of hundreds of millions of Americans and does not perform all that badly?

What is the alternative? Once the asymptotic notation is defined in terms of sets, it is onl y natural to manipulate it using set notation. If "the equal sign really means set inclusion", wh y not use set inclusion? I wish to emphasise that this reaches far beyond a purist 's aestheti c preferences. Indeed, it allows any number of big Oh's to be used in arbitrary set theoreti c formulae, with no fear of confusion or ambiguous meaning. It even allows tree mixing of 0 wit h fl and 8, as well as any set theoretic and arithmetic symbols appropriate to precisely conve y one's intended meaning. Why refuse this powerful tool? As two simple examples, one can write :

9(f (n )) = O(f (n))(1fl(f ( n ) )

(notice that the equal sign above really stands for standard set equality) ,

t This letter was written while the author was at the University of California at Berkeley ; it was supported in parts by NSF grant 21828. t The equal sign conventionally used in conjunction with asymptotic notation is^ not^ commutative ; examples of one-way equalities are :^ 5n'+3—O(n')^ and^ 0(n)O(n°).^ One should^ never write them the other way around such as 0(n') .=511 2+3 or 0(n'')I=O(n). (^2) The current author would add: "or E (set membership), in most cases".

17 .1-

and

2

2t

►ss"J E n( 3 n)no(n )

(this example is lifted from Vitanyi and Meertens (VM851). To be fair, I must admit that no ambiguity^ can arise from the usual asymptotic notation if , when reading, one systematically substitutes set inclusions (or set memberships, whichever make s sense) for equal signs. Still, there remains a difficulty with this conventional approach : how does one distinguish between set equality and proper containment? Assume, for instance, that you hav e figured out that the amount of time t(n) taken by some algorithm is in 0(2" +1 ). How could yo u carry the full meaning of the following equation with the conventional notation : t(n) E 0(2" +1 ) = 0(2") C 0(n!) C 0((n+l)!)?

Besides keeping with tradition, the only thing I can say in favour of using the equal sign t o mean set inclusion and set membership is that it is sometimes easier to typeset. This is certainl y true for electronic mail. Perhaps it was sufficient reason to submit the equal sign to such bizarr e treatment in the late nineteenth century, when this notation was invented. However, moder n typesetting facilities result in this consideration being mostly obsolete. I therefore propose that members of SIGACT adopt the following definitions (^) in their set theoretic sense, and use them as such, in accordance (^) with set theory : 0(t(n)) = { f : I E?. '* (^) I (3 c > 0)(3 no)(V n > no)[f(n) < et(n)] } ; and

n(t(n)) _ { f : 1V—+1R* (3 c > 0)(3 no)(V n > no)[f (n) > ct(n)] } ,

where Ft denotes the set of non-negative reals, and where t : ll\I —* IR*. The definition of 0(t(n) ) was already given above as the intersection of 0(t(n)) with n(t (n)), One can define o(t (n)) an d w(t (n )) similarly. For some applications, it is desirable to extend this notation to fu°-^tions undefined or takin g negative values on some or all of their domain up to no. For instance, one can freely use 0(n /log n) without worrying about the cases n =0 and n =1. (^) It can Also be useful to exten d this notation in the natural way to functions of more than one argument. It is important to keep in mind that "the primary purpose of notation is communication " [P85). The proposed switch to set theory would be intolerable if it resulted in a net decrease in expressive power. It is therefore crucial to allow the use of asymptotic notation within arithmeti c expressions. This can be achieved easily (as mentioned in [K76]), by extending the arithmeti c operators to sets of functions in the natural way : if X and Y are sets of functions, then (^) X +Y, for instance, denotes { (^) f +g I f EX and g E Y } , where function addition is pointwise. Similarly, if f (n) is a function and (^) X is a set of functions, then f (n)+X is an abbreviation fo r { f (n) } +X. (^) Nesting of asymptotic notation can also be given a systematic definition by usin g 0(X) to denote (^) u 0(t(n)), where (^) X is a set of functions , tEx Formally speaking, an new type of ambiguity arises from this use of arithmetic operators : does )O(n)) 2 stand for 0(n 2 ) or for the set of pair (^) of functions, each of which being in 0(n)? How about 2 C ) 7 Is this a powerset? I cannot deny the existence of these ambiguities, but the y do not cause any serious confusion in practice, as the context should allow to clarify the intende d meaning. The only case that must be handled with care is that of subtraction, but this can b e resolved by using the mathematically conventional backslash (^) "" to denote set difference , reserving "—" for arithmetic subtraction.

Perhaps the thought of saying that the time taken by an algorithm belongs to 0(.. .), or is in

0(.. .), instead of the usual is 0(.. .), seems strange at first. I maintain that this is a small price t o

pay for the possibility of (^) using the full power of set theory and its notation. People who hav e adopted my ideas over the years reported that it rapidly gets to sound quite natural. Moreover, I would like to share with you an interesting comment sent electronically to me on this topic : "'Red' is sometimes defined by philosophers as `the set of red things' ; so 'my car is red' is

4. Should fl(f(n)) be Infinitely-Often? In their second book, Aho, Hoperoft and^ Ullman^ suggest that^ fl(t (n )) should be an infinitely-often notion [AHU83). In other words, they suggest that one should define :

f1 (t(n)) {^ f : I (3 c > 0 )(V n o)(3 n ~ no)[f (n) > ct (n ))).

More recently, Vitanyi and Meertens wrote a paper to the same effect [VM851. (^) In fact, this ide a essentially goes back to Hardy and Littlewood's original definition [HL141. Although there ar e situations where one really means infinitely-often-SI, I decided to stay away from this can o f worms because it is very messy to manipulate mathematically. In their paper, Vitanyi an d

Meertens acknowledge the fact that "if g (n) E 8(f (n)), we may not, in general, conclude tha t

f (n) E 8(g(n ))". They then claim that "we have lost a pleasant property (.. .) however, we fee l that the gain is worth the loss". This could be so if nothing else were lost, but we also loos e

transitivity : one can no longer conclude that f (n) E 1(h (n )) from f (n) E f2(g(n )) an d

g(n) E fl(h (n )). Therefore, if algorithm A on input n calls algorithm 13 with (^) input 2n, and if th e time taken by algorithm B on input m is in 1(m 2 ), no lower bounds can be infered on the (^) runnin g time of A. Furthermore, whenever it would be needed, f1,(f (a)) can still be expressed as th e complement of o (f (n)), as long as one uses (^) a strict inequality, but no absolute values, in the definition of o(f (n )).

5. Discussio n A preliminary version of this letter was sent electronically over the theory networ k (theoryOuwisc .ARPA). About two dozen people responded, either electronically or in person a t STOC'85. Their comments ranged wildly from : "Bravo! I support your proposed change in th e asymptotic notation" and "I liked your paper very much" to "I'm afraid that we won't see m e marching in the streets over this one". One of the most interesting response was to the effect that defining asymptotic notation i n terms of sets has been common practice in parts of Europe for a long time. As early as 1962, an d perhaps earlier, Amsterdam freshmen were taught so in their basic Analysis class. Moreover , "students were required to read the asymptotic formulae as set inclusions ; if they failed to do so at an oral, they might flunk the test " [vEB85]. This may explain why Vitanyi and Meertens us e the set notation in their paper [VM85( without (^) even making a footnote of it, as if it wer e completely natural (which, of course, it is). It was reported to me that Knuth's reaction was that the marketplace should decide. I agree.

0. Brief Survey of' the Literatur e

Once again, in the first edition of his Volume 1 [K68[, Knuth does not mention tha t asymptotic notation should be defined in terms (^) of sets. This can also be said of Aho, Hoperof t and Ullman's book on algorithms (AHU74J, Garey and Johnson 's monograph on NP-completenes s (GJ79(, Horowitz and Sahni's book on algorithms [HS78), Papadimitriou and Steiglitz's book o n combinatorial algorithms (PS82) and Tarjan's monograph on network algorithms [T83J. However, many of these authors avoid one-way equalities by using asymptotic notation in prose only, neve r in equations, writing things like "the algorithm takes 0(n 2 ) time" or "f (n) is 0(n 2 )" (AHU74 , GJ79, T83).

In the second edition of his Volume I [K73[, Knuth replaced 11 lines on (^) page 105 with a different 9 lines, mentioning the fact that one may regard asymptotic notation (^) as defining sets. The notation is d irectly defined as sets in Purdom and Brown's book on the analysis of algorithm s [PB85[. Both these sources make free use of one-way equalities. In her book on algorithms (^) [Ba78] , Baase comes close to the proposal found in this letter : she defines 0(f (n)) (^) in the traditional way , but she defines f1(f (n)) as a set. She then says : "it is conventional to write 'g = 8(f )' o r 'g is 8(f )' rather than 'g E 0(f)', and goes on using one-way equalities.

The idea of manipulating asymptotic notation in accordance with set theory is howeve r anything but new, although it is still rather unusual in North America. Again, this is done withou t apologies in Vitanyi and Meertens' paper [VM85I. Ten years ago, Seiferas wrote his Ph .D. thesis this way 1S74, subsequently published in SFM781. The earliest full use of set theory I could find i n print on this subject is Blanchard ' s book on prime number theory [B1691. In his book, Blanchar d makes a point of defining asymptotic notation in an unconventional way : "Noun pensons qu (^) ' il y a une raison s4rieuse de modifier MgPrement I'emploi des notations 0 et o (.. .) On avail cett e situation choquante d ' avoir des 6galith dont les deux membres ne pouvaient pas titre permut6 s (.. .) La maniere dont nous utiliserons lee symbolee 0 et o est certainement plus correcte que l a maniere classique ".

  1. Acknowledgements I would like to (^) thank Sara Baase and Manuel Blum for their enthusiasm about (^) the use of se t theory in conjunction with asymptotic notation. Their moral support helped me write up this letter. I would also like to extend my thanks to Joan Feigenbaum, Oren Patashnik, Peter (^) van Emde Boas and Jeff Wolinsky for their very thorough comments, which does not necessarily impl y their approval of my proposal. Eric Bach pointed out Blanchard's book to me. I am grateful to Sayed Atef Banawan, Bard Bloom, Russel Brand, Anil Gangolli, FtGOrochester .ARPA, Eri c Kaltofen, Richard Karp, Eugene Lawler, Jerry Leichter, Pierre McKenzie, Albert Meyer, Joe l Seiferas and Allen van Gelder for their most useful electronic feedback. Finally, I would like to thank all those who personally communicated with me at STOC (^) ' 85.

References [AHU74) Aho, A. V ., J. E. Hoperoft and J. D. Ullman, The Design and Analysis of (^) Computer Algorithms, Addison-Wesley, Reading-MA, 1074. JAHU831 Aho, A. V., J. E. Hoperoft and J. D. Ullman, Data Structures and Algorithms, Addison-Wesley, Reading :MA , 1083. (13a781 Baase, S ., Computer Algorithms, Introduction to Design and Analysis, (^) Addison-Wesley, Reading-MA, 1078. [BI60] Blanchard, A ., Initiation It to (^) thlorie analytique des timbres premiers, Dunod, Reading:Paris, 1060. [BB88] Brassard, G. and P. Bratley, Introduction to Algorithmria, Prentice-Hall, Reading :NJ, 1988(1).

  1. Carey, M. R. and D. S. Johnson, Computers and Intractability : A Guide to (^) the Theory of NP-Completeness , Freeman, Reading:CA, 1070. [HL141 Hardy, G. H. and J. E. Littlewood, "Some problems cf (^) Diophantine approximation", Acts Mathematics, (^) VoL 37 , 1014, pp. 155-. (HS78J Horowitz, E. and S. Sahni, Flandamentals of Computer Algorithms, Computer Science Press, Reading:MD, 1978. (K68] Knuth, D. E., The Art of Computer Programming, Vol. 1 : FF,ndamental Algorithms, first edition, Addison-Wesley, Reading:MA, 1968. (K73] Knuth, D. E., The Art of (^) Computer Programming, Vol. 1 : Fundamental Algorithms, (^) second edition, Addison- Wesley, Reading:MA, 1973.

1K761 Knuth, D. E., "Big Omicron and Big Omega and Big Theta", SIGACT/NEii'S, VoL 8, no 2, 1076, pp. 18-24. [185] Leichter, J ., private electronic communication.

[PS82] Papadimitriou, C. H. and K. Steiglita, _Combinatorial Algorithm :_* Algorithms and Complexity, (^) Prentice-Hall, Reading.NJ, 1982.

(P851 Pstashnik, O., private electronic communication.

(PB85J Purdorn, P. W. and C. Brown, The Analysis of Algorithms, Holt, Rinehart (^) and Winston, Reading :NY, 1085. (S74J Seiferss, J. 1 ., Nondeterministic Time and (^) Space Complexity Classes, Department cf Electrical (^) Engineering an d Computer Science, MIT, 1974. (SFM78J Seiferas, J. I ., M. J. Fischer and A. R. Meyer, "Separating Nondeterministic Time Complexity Classes" , Journal of the ACM, VoL 25, no 1, 1078, pp. 146-.

Cl'83) Tarjan,^ R. E., Data^ Structtires and^ Network^ Algorithms,^ SIAM, Reading:PA,^ 1083. [vEB851 van Erode Boas, P ., private electronic communication. (VM85] Vitanyi, P. M. B. and L. Meertens, "Big Omega Versus the Wild Functions " , SIGACT/NEWS, (^) VoL 16, no 4, 1985 , pp. (^) 56. 50.