Discrete
Transcript of Discrete
Invitation to Discrete Mathematics
Ji�r�� Matou�sek Jaroslav Ne�set�ril
Rev� ��III���To be published by Oxford University Press�
�
Preface
Why should an introductory textbook on discrete mathematics havesuch a long preface� and what do we want to say in it� There aremany ways of choosing and presenting the material� and we �rst welist some of the guidelines of our writing� the reader may judge laterhow we succeeded in following these intentions� Then we add somemore technical remarks concerning a possible course based on thebook� the exercises� the existing literature� and so on�
So� here are some features which may perhaps distinguish thisbook from some others with a similar title and subject�
� Developing mathematical thinking� Our primary aim� besidesteaching some factual knowledge� and perhaps more importantthan that� is to lead the student to understand and appreciatemathematical notions� de�nitions� and proofs� to solve problemsrequiring more than just standard recipes� and to express math�ematical thoughts precisely and rigorously� Mathematical habitsmay give great advantages in many human activities� say in pro�gramming or in designing complicated systems�� It seems thatmany private �and well�paying companies are aware of this�They are not really interested in whether you know mathemat�ical induction by heart� but they may be interested in whetheryou have been trained to think about and absorb complicatedconcepts quicklyand mathematical theorems seem to providea good workout for such a training� The choice of speci�c ma�terial for this preparation is probably not essentialif you�reenchanted by algebra� we certainly won�t try to convert you tocombinatorics� But we believe that discrete mathematics is es�pecially suitable for such a �rst immersion into mathematics�since the initial problems and notions are more elementary thanin analysis� for instance� which starts with quite deep ideas atthe outset�
�On the other hand� one should keep in mind that in many other humanactivities� mathematical habits should better be suppressed�
vi Preface
� Methods� techniques� principles� In contemporary university cur�ricula� discrete mathematics usually means the mathematics of�nite sets� often including diverse topics like logic� �nite au�tomata� linear programming� or computer architecture� Our texthas a narrower scope� the book is essentially an introduction tocombinatorics and graph theory� and even there� everyone fa�miliar with these areas may miss some favorite topics �such asmatchings and network ows� Ramsey theory� or NP�comple�teness� to name just a few� We concentrate on relatively fewbasic methods and principles� aiming to display the rich vari�ety of mathematical techniques even at this basic level� and thechoice of material is subordinated to this�
� Joy� The book is written for a reader who� every now andthen� enjoys mathematics� and our boldest hope is that ourtext might help some readers to develop some positive feelingstowards mathematics that might have remained latent so far�In our opinion� this is a key prerequisite� an aesthetic pleasurefrom an elegant mathematical idea� sometimes mixed with a tri�umphant feeling when the idea was di�cult to understand orto discover� Not all people seem to have this gift� just as noteveryone can enjoy music� but without it� we imagine� studyingmathematics could be a most boring thing�
� All cards on the table� We try present arguments in full and to bemathematically honest with the reader� When we say that some�thing is easy to see� we really mean it� and if the reader can�t seeit then something is probably wrongwe may have misjudgedthe situation� but it may also indicate a reader�s problem infollowing and understanding the preceding text� Whenever pos�sible� we make everything self�contained �sometimes we indicateproofs of auxiliary results in exercises with hints� and if a proofof some result cannot be presented rigorously and in full �as isthe case for some results about planar graphs� say� we empha�size this and indicate the steps that aren�t fully justi�ed�
� CS� A large number of discrete mathematics students nowadaysare those specializing in computer science� Still� we believe thateven people who know nothing about computers and computing�or �nd these subjects repulsive� should have free access to dis�crete mathematics knowledge� so we have intentionally avoidedoverburdening the text with computer science terminology and
Preface vii
examples� However� we have not forgotten computer scientistsand have included several passages on e�cient algorithms andtheir analysis plus a number of exercises concerning algorithms�see below�
� Other voices� other rooms� In the covered material� there are sev�eral opportunities to demonstrate concepts from other branchesof mathematics in action� and while we intentionally restrict thefactual scope of the book� we want to emphasize these connec�tions� Our experience tells us that students like such applica�tions� provided that they are done thoroughly enough and notjust by hand�waving�
Prerequisites and readership� In most of the book� we do notassume much previous mathematical knowledge beyond a standardhigh�school course� Several more abstract notions that are very com�mon in all mathematics but go beyond the usual high�school level areexplained in the �rst chapter� In several places� we need some con�cepts from undergraduate�level algebra� and these are summarizedin an appendix� There are also a few excursions into calculus �en�countering notions such as limit� derivative� continuity� and so on�but we believe that a basic calculus knowledge should be generallyavailable to almost any student taking a course related to our book�
The readership can include early undergraduate students of math�ematics or computer science with a standard mathematical prepa�ration from high school �as is usual in most of Europe� say� andmore senior undergraduate or early graduate students �in the UnitedStates� for instance� Also nonspecialist graduates� such as biologistsor chemists� might �nd the text a useful source� For mathematicallymore advanced readers� the book could serve as a fast introductionto combinatorics�
Teaching it� This book is based on an undergraduate course wehave been teaching for a long time to students of mathematics andcomputer science at the Charles University in Prague� The secondauthor also taught parts of it at the University of Chicago� at Univer�sity of Bonn� and at Simon Fraser University in Vancouver� Our one�semester course in Prague ��� weeks� with one ���minute lecture andone ���minute tutorial per week typically included material fromChapters ���� with many sections covered only partially and someothers omitted completely �such as ���� ���� ���� ���� �������� ����
viii Preface
While the book sometimes proves one result in several ways� weonly presented one proof in a lecture� and alternative proofs wereoccasionally explained in the tutorials� Sometimes we inserted twolectures on generating functions ���������� or a lecture on the cyclespace of a graph ������
To our basic course outline� we have added a lot of additional �andsometimes more advanced material in the book� hoping that thereader might also read a few other things besides the sections that arenecessary for an exam� Some chapters� too� can serve as introductionsto more specialized courses �on the probabilistic method or on thelinear algebra method� The last three chapters and the last sectionin the chapter on counting spanning trees are of this type�
This type of smaller print is used for �second�level� material� namelythings which we consider interesting enough to include but less essential�These are additional clari�cations� comments� and examples� sometimeson a more advanced level than the basic text� The main text shouldmostly make sense even if this smaller�sized text is skipped�We also tried to sneak a lot of further related information into the
exercises� So even those who don�t intend to solve the exercises maywant to read them�
On exercises� At the end of most of the sections� the reader will�nd a smaller or larger collection of exercises� Some of them are onlyloosely related to the theme covered and are included for fun andfor general mathematical education� Solving at least some exercisesis an essential part of studying this book� although we know thatthe pace of modern life and human nature hardly allow the reader toinvest the time and e�ort to solve the majority of the ��� exerciseso�ered �although this might ultimately be the fastest way to masterthe covered material�
Mostly we haven�t included completely routine exercises requiringonly an application of some given �recipe�� such as �Apply the al�gorithm just explained to this speci�c graph�� We believe that mostreaders can check their understanding by themselves�
We classify the exercises into three groups of di�culty �no star�one star� and two stars� We imagine that a good student who hasunderstood the material of a given section should be able to solvemost of the no�star exercises� although not necessarily e�ortlessly�One�star exercises usually need some clever idea or some slightlymore advanced mathematical knowledge �from calculus� say� and�nally two�star exercises probably require quite a bright idea� Almost
Preface ix
all the exercises have short solutions� as far as we know� long andtedious computations can always be avoided� Our classi�cation ofdi�culty is subjective� and an exercise which looks easy to somemay be insurmountable for others� So if you can�t solve some no�starexercises don�t get desperate�
Some of the exercises are also marked by CS � a shorthand forcomputer science� These are usually problems in the design of e��cient algorithms� sometimes requiring an elementary knowledge ofdata structures� The designed algorithms can also be programmedand tested� thus providing material for an advanced programmingcourse� Some of the CS exercises with stars may serve �and haveserved as project suggestions� since they usually require a combi�nation of a certain mathematical ingenuity� algorithmic tricks� andprogramming skills�
Hints to many of the exercises are given in a separate chapterof the book� They are really hints� not complete solutions� and al�though looking up a hint spoils the pleasure of solving a problem�writing down a detailed and complete solution might still be quitechallenging for many students�
On the literature� In the citations� we do not refer to all sourcesof the ideas and results collected in this book� Here we would liketo emphasize� and recommend� one of the sources� namely a largecollection of solved combinatorial problems by Lov�asz ���� This bookis excellent for an advanced study of combinatorics� and also as anencyclopedia of many results and methods� It seems impossible toignore when writing a new book on combinatorics� and� for exam�ple� a signi�cant number of our more di�cult exercises are selectedfrom� or inspired by� Lov�asz� �less advanced problems� Biggs ��� is anice introductory textbook with a somewhat di�erent scope to ours�A bit more advanced ones �suitable as a continuation of our text�say are by Van Lint and Wilson ��� and Cameron ���� The beauti�ful introductory text in graph theory by Bollob�as ��� was probablywritten with somewhat similar goals as our own book� but it pro�ceeds at a less leisurely pace and covers much more on graphs� Avery recent textbook on graph theory at graduate level is by Dies�tel ���� The art of combinatorial counting and asymptotic analysisis wonderfully explained in a popular book by Graham� Knuth� andPatashnik ��� �and also in Knuth�s monograph ����� If you�re look�ing for something speci�c in combinatorics and don�t know where to
x Preface
start� we suggest the Handbook of Combinatorics ����� Other recom�mendations to the literature are scattered throughout the text� Thenumber of textbooks in discrete mathematics is vast� and we onlymention some of our favorite titles�
On the index� For most of the mathematical terms� especiallythose of general signi�cance �such as relation� graph� the index onlyrefers to their de�nition� Mathematical symbols composed of Latinletters �such as Cn are placed at the beginning of the appropriateletter�s section� Notation including special symbols �such as X n Y �G �� H and Greek letters are listed at the beginning of the index�
Acknowledgments� A preliminary Czech version of this book wasdeveloped gradually during our teaching in Prague� We thank ourcolleagues and teaching assistants in the Department of AppliedMathematics of the Charles University and our students for a stim�ulating environment and helpful comments on the text and exer�cises� In particular� Pavel Socha� Eva Matou skov�a� Tom�a s Holan�and Robert Babilon discovered a number of errors in the Czechversion� Martin Klazar and Ji r�! Otta compiled a list of few dozenproblems and exercises� this list was a starting point of our collec�tion of exercises� Our colleague Jan Kratochv�!l provided invaluableremarks based on his experience in teaching the same course� Wethank Tom�a s Kaiser for substantial help in translating one chapterinto English� Adam Dingle and Tim Childers helped us with somecomments to English at early stages of the translation� Jan Nekov�a rwas so kind as to leave the number theory peaks for a moment andprovide pointers to an elementary proof of Fact �������
Several people read parts of the English version at various stagesand provided insights that would probably never have occurred tous� Special thanks go to Je� Stopple for visiting us in Prague� care�fully reading the whole manuscript� and sharing some of his teachingwisdom with us� We are much indebted to Mari Inaba and HelenaNe set rilov�a for comments that were very useful and di�erent fromthose made by most of other people� Also opinions in several re�ports obtained by Oxford University Press from anonymous refereeswere truly helpful� Most of the �nishing and polishing work on thebook was done by the �rst author during a visit to the ETH Z"urich�Emo Welzl and the members of his group provided a very pleasantand friendly environment� even after they were each asked to readthrough a chapter� and so the help of Hans�Martin Will� Beat Tra�
Preface xi
chsler� Bernhard von Stengel� Lutz Kettner� Joachim Giesen� BerndG"artner� Johannes Bl"omer� and Artur Andrzejak is gratefully ac�knowledged� We also thank Hee�Kap Ahn for reading a chapter�
S"onke Adlung has been extremely nice to us and very helpfulduring the editorial process� We would also like to thank Karel Hor�akfor several expert suggestions helping the �rst author in his strugglewith the layout of the book �unfortunately� the times when booksused to be typeset by professional typographers seem to be over� andJana Chleb�!kov�a for a long list of minor typographic corrections�
Almost all the �gures were drawn by the �rst author using thegraphic editor Ipe ���� In the name of humankind� we thank OtfriedCheong �formerly Schwarzkopf for its creation�
A �nal appeal� A long mathematical text usually contains a sub�stantial number of mistakes� Compared to various preliminary ver�sions of this book� we have corrected a large number of them� butcertainly some still remain� So we plead with readers who discovererrors� bad formulations� wrong hints to exercises� etc�� to let us knowabout them��
Prague
February ����
J� M�J� N�
�Please send us e�mails concerning this book to idm�kam�ms�mff�cuni�cz�Hopefully� the readers will understand that we may not be able to answerall correspondence in this matter� If there is a substantial feedback from thereaders� we will set up an Internet home page concerning the book underhttp���www�ms�mff�cuni�cz�acad�kam�idm�
xii Preface
Contents
� Introduction and basic concepts ���� An assortment of problems ���� Numbers and sets� notation ���� Mathematical induction and other proofs ����� Functions ����� Relations ����� Equivalences ����� Ordered sets ��
� Combinatorial counting ����� Functions and subsets ����� Permutations and factorials ����� Binomial coe�cients ����� Estimates� an introduction ����� Estimates� the factorial function ����� Estimates� binomial coe�cients ����� Inclusion�exclusion principle ����� The hatcheck lady # co� ��
� Graphs� an introduction ����� The notion of a graph� isomorphism ����� Subgraphs� components� adjacency matrix ������ Graph score ������ Eulerian graphs ������ An algorithm for an Eulerian tour ������ Eulerian directed graphs ������ ��connectivity ���
� Trees ������ De�nition and characterizations of trees ������ Isomorphism of trees ������ Spanning trees of a graph ������ The minimum spanning tree problem ������ Jarn�!k�s algorithm and Bor$uvka�s algorithm ���
xiv Contents
� Drawing graphs in the plane ������ Drawing in the plane and on other surfaces ������ Cycles in planar graphs ������ Euler�s formula ������ Coloring maps� the four�color problem ���
� Doublecounting ������ Parity arguments ������ Sperner�s theorem on independent systems ������ A result in extremal graph theory ���
The number of spanning trees ������ The result ������ A proof via score ������ A proof with vertebrates ������ A proof using the Pr"ufer code ������ A proof working with determinants ���
� Finite projective planes ������ De�nition and basic properties ������ Existence of �nite projective planes ������ Orthogonal Latin squares ������ Combinatorial applications ���
� Probability and probabilistic proofs ������ Proofs by counting ������ Finite probability spaces ������ Random variables and their expectation ������ Several applications ���
� Generating functions ������� Combinatorial applications of polynomials ������� Calculation with power series ������� Fibonacci numbers and the golden section ������� Binary trees ������� On rolling the dice ������� Random walk ������� Integer partitions ���
�� Applications of linear algebra ������� Block designs ������� Fisher�s inequality ���
Contents xv
���� Covering by complete bipartite graphs ������� Cycle space of a graph ������� Circulations and cuts� cycle space revisited ������� Probabilistic checking ���
Appendix� Prerequisites from algebra ���
Bibliography ���
Hints to selected exercises ���
Index ���
xvi Contents
�
Introduction and basicconcepts
In this introductory chapter� we �rst give a sample of the problemsand questions to be treated in the book� Then we explain some basicnotions and techniques� mostly fundamental and simple ones com�mon to most branches of mathematics� We assume that the readeris already familiar with many of them or has at least heard of them�Thus� we will mostly review the notions� give precise formal de�ni�tions� and point out various ways of capturing the meaning of theseconcepts by diagrams and pictures� A reader preferring a more de�tailed and thorough introduction to these concepts may refer to thebook by Stewart and Tall ���� for instance�
Section ��� presents several problems to be studied later on inthe book and some thoughts on the importance of mathematicalproblems and similar things�
Section ��� is a review of notation� It introduces some commonsymbols for operations with sets and numbers� such as � for setunion or
Pfor summation of a sequence of numbers� Most of the
symbols are standard� and the reader should be able to go throughthis section fairly quickly� relying on the index to refresh memorylater on�
In Section ���� we discuss mathematical induction� an importantmethod for proving statements in discrete mathematics� Here it issu�cient to understand the basic principle� there will be many op�portunities to see and practice various applications of induction insubsequent chapters� We will also say few words about mathematicalproofs in general�
Section ��� recalls the notion of a function and de�nes specialtypes of functions� injective functions� surjective functions� and bi�jections� These terms will be used quite frequently in the text�
� Introduction and basic concepts
Sections ��� through ��� deal with relations and with special typesof relations� namely equivalences and orderings� These again belongto the truly essential phrases in the vocabulary of mathematics� How�ever� since they are simple general concepts which we have not yet eshed out by many interesting particular examples� some readersmay �nd them �too abstract�a polite phrase for �boring�on the�rst reading� Such readers may want to skim through these sectionsand return to them later� For instance� ordered sets �Section ��� areonly needed for a full understanding of Section ��� and for some ex�ercises in this book� but they certainly should be a part of any deepermathematical education� �When learning a new language� say� it isnot very thrilling to memorize the grammatical forms of the verb �tobe�� but after some time you may �nd it di�cult to speak uentlyknowing only �I am� and �he is�� Well� this is what we have to do inthis chapter� we must review some of the language of mathematics�
��� An assortment of problems
Let us look at some of the problems we are going to consider in thisbook� Here we are going to present them in a popular form� so youmay well know some of them as puzzles in recreational mathematics�
A well�known problem concerns three houses and three wells�Once upon a time� three fair white houses stood in a meadow ina distant kingdom� and there were three wells nearby� their waterclean and fresh� All was well� until one day a seed of hatred was sown��ghts started among the three households and would not cease� andno reconciliation was in sight� The people in each house insisted thatthey have three pathways leading from their gate to each well� threepathways which should not cross any of their neighbors� paths� Canthey ever �nd paths that will satisfy everyone and let peace set in�
A solution would be possible if there were only two wells�
��� An assortment of problems �
But with three wells� there is no hope �unless these proud men andwomen would be willing to use tunnels or bridges� which sounds quiteunlikely� Can you state this as a mathematical problem and provethat it has no solution�
Essentially� this is a problem about drawing in the plane� Manyother problems to be studied in this book can also be formulated interms of drawing� Can one draw the following picture without liftingthe pencil from the paper� drawing each line only once�
And what about this one�
If not� why not� Is there a simple way to distinguish pictures thatcan be drawn in this way from those that cannot� �And� can you�nd nice accompanying stories to this problem and the ones below�
For the subsequent set of problems� draw � dots in the plane insuch a way that no � of them lie on a common line� �The number � isquite arbitrary� in general we could consider n such dots� Connectsome pairs of these points by segments� obtaining a picture like thefollowing�
What is the maximum number of segments that can be drawn so thatno triangle with vertices at the dots arises� The following picture has�� segments�
� Introduction and basic concepts
Can you draw more segments for � dots with no triangle� Probablyyou can� But can you prove your result is already the best possible�
Next� suppose that we want to draw some segments so that anytwo dots can be connected by a path consisting of the drawn seg�ments� The path is not allowed to make turns at the crossings of thesegments� only at the dots� so the left picture below gives a validsolution while the right one doesn�t�
What is the minimum number of segments we must draw� How manydi�erent solutions with this minimum number of segments are there�And how can we �nd a solution for which the total length of all thedrawn segments is the smallest possible�
All these problems are popular versions of simple basic questionsin graph theory� which is one of main subjects of this book �treatedin Chapters �� �� and �� For the above problems with � dots in theplane� it is easily seen that the way of drawing the dots is immaterial�all that matters is which pairs of dots are connected by a segmentand which are not� Most branches of graph theory deal with problemswhich can be pictured geometrically but in which geometry doesn�treally play a role� On the other hand� the problem about wells andhouses belongs to a �truly� geometric part of graph theory� It isimportant that the paths should be built in the plane� If the housesand wells were on a tiny planet shaped like a tire�tube then therequired paths would exist�
��� An assortment of problems �
Another important theme of this book is combinatorial counting�treated in Chapters � and ��� The problems there usually begin with�How many ways are there� � � � or something similar� One questionof this type was mentioned in our �� dots� series �and it is a nicequestionthe whole of Chapter � is devoted to it� The reader hasprobably seen lots of such problems� let us add one more� How manyways are there to divide n identical coins into groups� For instance�� coins can be divided in � ways� � % � % � % � �� groups of � coineach� � % � % �� � % �� and � �all in one group� which is not reallya �division� in the sense most people understand it� but what doyou expect from mathematicians�� For this problem� we will notbe able to give an exact formula� such a formula does exist but itsderivation is far beyond the scope of this book� Nonetheless� we willat least derive estimates for the number in question� This number isa function of n� and the estimates will allow us to say �how fast� thisfunction grows� compared to simple and well�known functions like n�
or �n� Such a comparison of complicated functions to simple ones isthe subject of the so�called asymptotic analysis� which will also betouched on below and which is important in many areas� for instancefor comparing several algorithms which solve the same problem�
Although the problems presented may look like puzzles� each ofthem can be regarded as the starting point of a theory with numerousapplications� both in mathematics and in practice�
In fact� distinguishing a good mathematical problem from a bad oneis one of the most di�cult things in mathematics� and the �quality� ofa problem can often be judged only in hindsight� after the problem hasbeen solved and the consequences of its solution mapped� What is a good
� Introduction and basic concepts
problem� It is one whose solution will lead to new insights� methods�or even a whole new fruitful theory� Many problems in recreationalmathematics are not good in this sense� although their solution mayrequire considerable skill or ingenuity�A pragmatically minded reader might also object that the problems
shown above are useless from a practical point of view� Why take awhole course about them� a skeptic might say� when I have to learn somany practically important things to prepare for my future career� Ob�jections of this sort are quite frequent and cannot be simply dismissed� ifonly because the people controlling the funding are often pragmaticallyminded�One possible answer is that for each of these puzzle�like problems�
we can exhibit an eminently practical problem that is its cousin� Forinstance� the postal delivery service in a district must deliver mail to allhouses� which means passing through each street at least once� What isthe shortest route to take� Can it be found in a reasonable time using asupercomputer� Or with a personal computer� In order to understandthis postal delivery problem� one should be familiar with simple resultsabout drawing pictures without lifting a pencil from the paper�Or� given some placement of components of a circuit on a board� is
it possible to interconnect them in such a way that the connections goalong the surface of the board and do not cross each other� What is themost economical placement of components and connections� say usingthe smallest area of the board� Such questions are typical of VLSI designdesigning computer chips and similar things� Having learned about thethree�wells problem and its relatives or� scienti�cally speaking� aboutplanar graphs it is much easier to grasp ways of designing the layoutof integrated circuits�These �practical� problems also belong to graph theory� or to a
mixture of graph theory and the design of e�cient algorithms� Thisbook doesn�t provide a solution to them� but in order to comprehenda solution in some other book� or even to come up with a new goodsolution� one should master the basic concepts �rst�We would also like to stress that the most valuable mathematical
research was very seldom directly motivated by practical goals� Somegreat mathematical ideas of the past have only found applications quiterecently� Mathematics does have impressive applications it might beeasier to list those human activities where it is not applied than thosewhere it is� but anyone trying to restrict mathematical research to thedirectly applicable parts would be left with a lifeless fragment with mostof the creative power gone�
Exercises are unnecessary in this section� Can you solve some ofthe problems sketched here� or perhaps all of them� Even if you tryand get only partial results or fail completely� it will still be of great
��� Numbers and sets� notation �
help in reading further�
So what is this discrete mathematics they�re talking about� thereader may rightfully ask� The adjective �discrete� here is an oppo�site of �continuous�� Roughly speaking� objects in discrete mathematics�such as the natural numbers� are clearly separated and distinguishablefrom each other and we can perceive them individually like trees ina forest which surrounds us� In contrast� for a typical �continuous�object� such as the set of all points on a line segment� the points areindiscernible like the trees in a forest seen from a high��ying airplane�We can focus our attention on some individual points of the segmentand see them clearly� but there are always many more points nearbythat remain indistinguishable and form the totality of the segment�According to this explanation� such parts of mathematics as algebra
or set theory might also be considered �discrete�� But in the commonusage of the term� discrete mathematics is most often understood asmathematics dealing with �nite sets� In many current university curric�ula� a course on discrete mathematics has quite a wide range� includingsome combinatorics� counting� graph theory� but also elements of math�ematical logic� some set theory� basics from the theory of computing�nite automata� formal languages� elements of computer architecture�and other things� We prefer a more narrowly focussed scope� so perhapsa more descriptive title for this book would be �Invitation to combina�torics and graph theory�� covering most of the contents� But the nameof the course we have been teaching happened to be �Discrete mathe�matics� and we decided to stick to it�
��� Numbers and sets� notation
Number domains� For the set of all natural numbers� i�e� the setf�� �� �� � � �g� we reserve the symbol N� The letters n�m� k� i� j� p andpossibly some others usually represent natural numbers�
Using the natural numbers� we may construct other well�knownnumber domains� the integers� the rationals� and the reals �and alsothe complex numbers� but we will seldom hear about them here�
The integer numbers or simply integers arise from the naturalnumbers by adding the negative integer numbers and �� The set ofall integers is denoted by Z�
The rational numbers are fractions with integer numerator anddenominator� This set is usually denoted by Q but we need notintroduce any symbol for it in this book� The construction of theset R of all real numbers is more complicated� and it is treated inintroductory courses of mathematical analysis� Famous examples ofreal numbers which are not rational are numbers such as
p�� some
� Introduction and basic concepts
important constants like �� and generally numbers whose decimalnotation has an in�nite and aperiodic sequence of digits followingthe decimal point� such as ���������������� � � ��
The closed interval from a to b on the real axis is denoted by �a� b��and the open interval with the same endpoints is written as �a� b�
Operations with numbers� Most symbols for operations withnumbers� such as % for addition�
pfor square root� and so on�
are generally well known� We write division either as a fraction� orsometimes with a slash� i�e� either in the form a
b or as a�b�We introduce two less common functions� For a real number x�
the symbol bxc is called� the lower integer part of x �or the �oor
function of x� and its value is the largest integer smaller than orequal to x� Similarly dxe� the upper integer part of x �or the ceilingfunction� denotes the smallest integer greater than or equal to x� Forinstance� b�����c � �� b����c � ��� d����e � �� d��� e � �� bp�c � ��
Later on� we will introduce some more operations and functionsfor numbers� which have an important combinatorial meaning andwhich we will investigate in more detail� Examples are n� and
�nk
��
Sums and products� If a�� a�� � � � � an are real numbers� their suma� % a� % � � �% an can also be written using the summation sign
P�
in the formnXi��
ai�
This notation somewhat resembles the FOR loop in many program�ming languages� Here are a few more examples�
�Xj��
�
�j�
�
�%
�
�%
�
�%
�
��
�Xi��
�
�j�
�
�j%
�
�j%
�
�j%
�
�j�
�
j
nXi��
nXj��
�i% j �nXi��
��i% � % �i% � % � � � % �i% n
�nXi��
�ni% �� % � % � � �% n
�In the older literature� one often �nds �x� used for the same function�
��� Numbers and sets� notation �
� n
� nXi��
i
�% n�� % � % � � �% n
� �n�� % � % � � �% n�
Similarly as sums are written usingP
�which is the capital Greekletter �sigma�� from the word sum� products may be expressed usingthe sign
Q�capital Greek �pi�� For example�
nYi��
i% �
i�
�
�� ��� � � � � n% �
n� n% ��
Sets� Another basic notion we will use is that of a set� Most likelyyou have already encountered sets in high school �and� thanks tothe permanent modernization of the school system� maybe even inelementary school� Sets are usually denoted by capital letters�
A�B� � � � �X� Y� � � � �M�N� � � �
and so on� and the elements of sets are mostly denoted by lowercaseletters� a� b� � � �� x� y� � � �� m�n� � � ��
The fact that a set X contains an element x is traditionally writ�ten using the symbol �� which is a somewhat stylized Greek letter��epsilon�� The notation x � X is read �x is an element of X���x belongs to X�� �x is in X�� and so on�
Let us remark that the concept of a set and the symbol � are so�called primitive notions� This means that we do not de�ne them usingother �simpler� notions unlike the rational numbers� say� which arede�ned in terms of the integers� To understand of the concept of a set�we rely on intuition supported by numerous examples in this book� Itturned out at the beginning of the � th century that if such an intuitivenotion of a set is used completely freely� various strange situations� theso�called paradoxes� may arise�� In order to exclude such paradoxes�the theory of sets has been rebuilt on a formalized basis� where allproperties of sets are derived formally from several precisely formulatedbasic assumptions axioms� For the sets used in this text� which aremostly �nite� we need not be afraid of any paradoxes� and so we cankeep relying on the intuitive concept of a set�
�The most famous one is probably Russell�s paradox� One possible formulationis about an army barber� An army barber is supposed to shave all soldiers whodo not shave themselves�should he� as one of the soldiers� shave himself or not�This paradox can be translated into a rigorous mathematical language and itimplies the inconsistency of notions like the set of all sets�
� Introduction and basic concepts
The set with elements �� ��� and �� is written as f�� ��� ��g� This�and also the notations f��� �� ��g and f�� ��� �� ��� ��� �g� express thesame thing� Thus� a multiple occurrence of the same element is ig�nored� the same element cannot be contained twice in the same set�Three dots �an ellipsis in f�� �� �� �� � � �g mean �and further simi�larly� using the same pattern�� i�e� this notation means the set of alleven natural numbers� The appropriate pattern should be apparentat �rst sight� For instance� f��� ��� ��� � � �g is easily understandableas the set of all powers of �� while f�� �� �� � � �g may be less clear�
Ordered and unordered pairs� The symbol fx� yg denotes theset containing exactly the elements x and y� as we already know� Inthis particular case� the set fx� yg is sometimes called the unorderedpair of x and y� Let us recall that fx� yg is the same as fy� xg� andif x � y� then fx� yg is a ��element set�
We also introduce the notation �x� y for the ordered pair ofx and y� For this construct� the order of the elements x and y isimportant� We thus assume the following�
�x� y � �z� t if and only if x � z and y � t� ����
Interestingly� the ordered pair can be de�ned using the notion ofunordered pair� as follows�
x� y � ffxg� fx� ygg �
Verify that ordered pairs de�ned in this way satisfy the condition ����However� in this text it will be simpler for us to consider x� y as anotherprimitive notion�
Similarly� we write �x�� x�� � � � � xn for the ordered n�tuple consist�ing of elements x�� x�� � � � � xn� A particular case of this convention iswriting a point in the plane with coordinates x and y as �x� y� andsimilarly for points or vectors in higher�dimensional spaces�
De�ning sets� More complicated and interesting sets are usuallycreated from known sets using some rule� The sets of all squares ofnatural numbers can be written
fi�� i �Ng
or also
fn � N� there exists k � N such that k� � ng
��� Numbers and sets� notation ��
or using the symbol � for �there exists��
fn � N� �k � N �k� � ng�
Another example is a formal de�nition of the open interval �a� bintroduced earlier�
�a� b � fx � R� a � x � bg�
Note that the symbol a� b may mean either the open interval� oralso the ordered pair consisting of a and b� These two meanings mustand usually can be distinguished by the context� This is not at alluncommon in mathematics� many symbols� like parentheses in this case�are used in several di�erent ways� For instance� a� b also frequentlydenotes the greatest common divisor of natural numbers a and b butwe avoid this meaning in this book�With modern typesetting systems� it is no problem to use any kind
of alphabets and symbols including hieroglyphs� so one might think ofchanging the notation in such cases� But mathematics tends to be ratherconservative and the existing literature is vast� and so such notationalinventions are usually short�lived�
The empty set� An important set is the one containing no elementat all� There is just one such set� and it is customarily denoted by �and called the empty set� Let us remark that the empty set can bean element of another set� For example� f�g is the set containing theempty set as an element� and so it is not the same set as ��Set systems� In mathematics� we often deal with sets whose ele�ments are other sets� For instance� we can de�ne the set
M � ff�� �g� f�� �� �g� f�� �� �g� f�gg�
whose elements are � sets of natural numbers� more exactly � subsetsof the set f�� �� �� �g� One meets such sets in discrete mathematicsquite frequently� To avoid saying a �set of sets�� we use the notionsset system or family of sets� We could thus say that M is a system ofsets on the set f�� �� �� �g� Such set systems are sometimes denotedby calligraphic capital letters� such as M�
However� it is clear that such a distinction using various types of let�ters cannot always be quite consistent�what do we do if we encountera set of sets of sets�
�� Introduction and basic concepts
The system consisting of all possible subsets of some set X isdenoted by the symbol� �X and called the power set of X� Anothernotation for the power set common in the literature is P�X�
Set size� A large part of this book is devoted to counting variouskinds of objects� Hence a very important notation for us is that forthe number of elements of a �nite set X� We write it using the samesymbol as for the absolute value of a number� jXj�A more general notation for sums and products� Sometimesit is advantageous to use a more general way to write down a sumthan using the pattern
Pni�� ai� For instance�X
i�f�������gi�
means the sum �� % �� % �� % ��� Under the summation sign� we�rst write the summation variable and then we write out the set ofvalues over which the summation is to be performed� We have a lotof freedom in denoting this set of values� Sometimes it can in partbe described by words� as in the following�X
i� ��i���i a prime
i � � % � % � % ��
Should the set of values for the summation be empty� we de�ne thevalue of the sum as �� no matter what appears after the summationsign� For example�
�Xi��
�i% �� � ��X
i�f�������gi odd
i� � ��
A similar �set notation� can also be employed for products� Anempty product� such as
Qj� ��j�� �
j � is always de�ned as � �not �as for an empty sum�
Operations with sets� Using the primitive notion of set member�ship� �� we can de�ne further relations among sets and operationswith sets� For example� two sets X and Y are considered identical�equal if they have the same elements� In this case we write X � Y �
�This notation may look strange� but it is traditional and has its reasons�For instance� it helps to remember that an n�element set has �n subsets� seeProposition �� ���
��� Numbers and sets� notation ��
Other relations among sets can be de�ned similarly� If X�Y aresets� X � Y �in words� �X is a subset of Y � means that eachelement of X also belongs to Y �
The notation X � Y sometimes denotes that X is a subset of Ybut X is not equal to Y � This distinction between � and � is not quiteuni�ed in the literature� and some authors may use � synonymouslywith our ��The notations X � Y �the union of X and Y and X Y �the
intersection of X and Y can be de�ned as follows�
X � Y � fz� z � X or z � Y g� X Y � fz� z � X and z � Y g�
If we want to express that the sets X and Y in the considered unionare disjoint� we write the union as X &�Y � The expression X nY is thedi�erence of the sets X and Y � i�e� the set of all elements belongingto X but not to Y �
Enlarged symbols � and may be used in the same way as thesymbols
Pand
Q� So� if X�� X�� � � � �Xn are sets� their union can be
writtenn�i��
Xi ����
and similarly for intersection�
Note that this notation is possible or correct only because theoperations of union and intersection are associative� that is� we have
X � Y � Z � X � Y � Z
andX � Y � Z � X � Y � Z
for any triple X�Y� Z of sets� As a consequence� the way of �parenthe�sizing� the union of any �� and generally of any n� sets is immaterial�and the common value can be denoted as in ���� The operations �and � are also commutative� in other words they satisfy the relations
X � Y � Y �X�
X � Y � Y �X�The commutativity and the associativity of the operations � and � arecomplemented by their distributivity� For any sets X�Y� Z we have
X � Y � Z � X � Y � X � Z�
�� Introduction and basic concepts
X � Y � Z � X � Y � X � Z�The validity of these relations can be checked by proving that any
element belongs to the left�hand side if and only if it belongs to the right�hand side� The relations can be generalized for an arbitrary number ofsets as well� For instance�
A �� n�i��
Xi
��
n�i��
A �Xi�
A �� n�i��
Xi
��
n�i��
A �Xi�
Such relations can be proved by induction� see Section ��� below� Otherpopular relations for sets are
X n A�B � X nA� X nB and X n A�B � X nA� X nB
the so�called de Morgan laws� and their generalizations
X n� n�i��
Ai
��
n�i��
X nAi
X n� n�i��
Ai
��
n�i��
X nAi�
The last operation to be introduced here is the Cartesian product�denoted by XY � of two sets X and Y � The Cartesian product of Xand Y is the set of all ordered pairs of the form �x� y� where x � Xand y � Y � Written formally�
X Y � f�x� y� x � X� y � Y g �
Note that generallyXY is not the same as Y X� i�e� the operationis not commutative�
The name �Cartesian product� comes from a geometric interpreta�tion� If� for instance� X � Y � R� then X �Y can be interpreted as allpoints of the plane� since a point in the plane is uniquely described by anordered pair of real numbers� namely its Cartesian coordinates��thex�coordinate and the y�coordinate Fig� ���a� This geometric viewcan also be useful for Cartesian products of sets whose elements are notnumbers Fig� ���b�
�These are named after their inventor� Ren�e Descartes�
��� Numbers and sets� notation ��
a
b
a� b
a b c d
�
�
�a� � b� �
c� �
X
Y X � Y
a b
Fig� ��� Illustrating the Cartesian product� a R � R� b X � Y for
�nite sets X�Y �
The Cartesian product of a set X with itself� i�e� X X� mayalso be denoted by X��
Exercises
�� Which of the following formulas are correct�
a b �n����
� c � bn�� c� n�
b bn�k� c � bn� c� bk�c�c dbxce � dxe for a real number x�d dbxc� byce � bxc� byc�
�� �Prove that the equality bpxc � bpbxcc holds for any positive realnumber x�
�� a De�ne a �parenthesizing� of a union of n setsSni��Xi� Similarly�
de�ne a �parenthesizing� of a sum of n numbersPn
i�� ai�
b Prove that any two parenthesizings of the intersectionTni��Xi
yield the same result�
c How many ways are there to parenthesize the union of � setsA � B � C �D�d ��Try to derive a formula or some other way to count the numberof ways to parenthesize the union of n sets
Sni��Xi�
�� True or false� If �X � �Y holds for two sets X and Y � then X � Y �
�� Is a �cancellation� possible for the Cartesian product� That is� ifX � Y � X � Z holds for some sets X�Y� Z� does it necessarily fol�low that Y � Z�
�� Prove that for any two sets A�B we have
A nB � B nA � A � B n A �B�
�� Introduction and basic concepts
�� �Consider the numbers �� �� � � � � � � Show that among any � � ofthem� two numbers exist such that one divides the other one�
�� In this problem� you can test your ability to discover simple but �hid�den� solutions� Divide the following �gure into � parts� all of them con�gruent they only di�er by translation� rotation� and possibly by a mir�ror re�ection� All the bounding segments in the �gure have length ��and the angles are � � �� � and �� degrees�
��� Mathematical induction and other proofs
Let us imagine that we want to calculate� say� the sum � % � % �� %�� % � � � % �n �
Pni�� �
i �and that we can�t remember a formulafor the sum of a geometric progression� We suspect that one canexpress this sum by a nice general formula valid for all the n� Bycalculating numerical values for several small values of n� we canguess that the desired formula will most likely be �n���� But evenif we verify this for a million speci�c values of n with a computer� thisis still no proof� The million�and��rst number might� in principle� bea counterexample� The correctness of the guessed formula for all ncan be proved by so�called mathematical induction� In our case� wecan proceed as follows�
�� The formulaPn
i�� �i � �n� � � holds for n � �� as one can
check directly�
�� Let us suppose that the formula holds for some value n � n��We prove that it also holds for n � n� % �� Indeed� we have
n��Xi��
�i �
� n�Xi��
�i�% �n���
The sum in parentheses equals �n���� by our assumption �thevalidity for n � n�� Hence
n��Xi��
�i � �n�� � � % �n�� � � � �n�� � � � �n�� � ��
This is the required formula for n � n� % ��
��� Mathematical induction and other proofs ��
This establishes the validity of the formula for an arbitrary n� bystep �� the formula is true for n � �� by step � we may thus inferit is also true for n � � �using step � with n� � �� then� again bystep �� the formula holds for n � �� � � � and in this way we can reachany natural number� Note that this argument only works becausethe value of n� in step � was quite arbitrary� We have made thestep from n� to n�%�� where any natural number could equally wellappear as n��
Step � in this type of proof is called the inductive step� The as�sumption that the statement being proved is already valid for somevalue n � n� is called the inductive hypothesis�
One possible general formulation of the principle of mathematicalinduction is the following�
����� Proposition� Let X be a set of natural numbers with the
following properties�
�i� The number � belongs to X�
�ii� If some natural number n is an element of X� then the number
n% � belongs to X as well�
Then X is the set of all natural numbers �X � N��
In applications of this scheme� X would be the set of all numbersn such that the statement being proved� S�n� is valid for n�
The scheme of a proof by mathematical induction has many vari�ations� For instance� if we need to prove some statement for all n � ��the �rst step of the proof will be to check the validity of the state�ment for n � �� As an inductive hypothesis� we can sometimes usethe validity of the statement being proved not only for n � n�� butfor all n � n�� and so on� these modi�cations are best mastered byexamples�
Mathematical induction can either be regarded as a basic property ofnatural numbers an axiom� i�e� something we take for granted withouta proof� or be derived from the following other basic property axiom�Any nonempty subset of natural numbers possesses a smallest element�This is expressed by saying that the usual ordering of natural numbersby magnitude is a well�ordering� In fact� the principle of mathematicalinduction and the well�ordering property are equivalent to each other��
and either one can be taken as a basic axiom for building the theory ofnatural numbers�
�Assuming that each natural number n � has a unique predecessor n� �
�� Introduction and basic concepts
Proof of Proposition ����� from the well�ordering property�For contradiction� let us assume that a set X satis�es both i and ii�but it doesn�t contain all natural numbers� Among all natural numbersn not lying in X � let us choose the smallest one and denote it by n��By condition i we know that n� � �� and since n� was the smallestpossible� the number n� � � is an element of X � However� using ii weget that n� is an element of X � which is a contradiction� �
Let us remark that this type of argument saying �Let n� be thesmallest number violating the statement we want to prove� and deriv�ing a contradiction� namely that a yet smaller violating number mustexist sometimes replaces mathematical induction� Both ways� this oneand induction� essentially do the same thing� and it depends on thecircumstances or personal preferences which one is actually used�
We will use mathematical induction quite often� It is one of ourbasic proof methods� and the reader can thus �nd many examplesand exercises on induction in subsequent chapters�
Mathematical proofs and notquite proofs� Mathematicalproof is an amazing invention� It allows one to establish the truth ofa statement beyond any reasonable doubt� even when the statementdeals with a situation so complicated that its truth is inaccessible todirect evidence� Hardly anyone can see directly that no two naturalnumbers m�n exist such that m
n �p� and yet we can trust this
fact completely� because it can be proved by a chain of simple logicalsteps�
Students often don�t like proofs� even students of mathematics�One reason might be that they have never experienced satisfactionfrom understanding an elegant and clever proof or from making anice proof by themselves� One of our main goals is to help the readerto acquire the skill of rigorously proving simple mathematical state�ments�
A possible objection is that most students will never need suchproofs in their future jobs� We believe that learning how to prove math�ematical theorems helps to develop useful habits in thinking� such asworking with clear and precise notions� exactly formulating thoughtsand statements� and not overlooking less obvious possibilities� For in�stance� such habits are invaluable for writing software that doesn�t crashevery time the circumstances become slightly non�standard�
The art of �nding and writing proofs is mostly taught by exam�ples� by showing many �hopefully correct and �good� proofs to the
�We will not even try to say what a proof is and how to do one�
��� Mathematical induction and other proofs ��
student and by pointing out errors in the student�s own proofs� Thelatter �negative� examples are very important� and since a book isa one�way communication device� we decided to include also a fewnegative examples in this book� i�e� students� attempts at proofs withmistakes which are� according to our experience� typical� These in�tentionally wrong proofs are presented in a special font like this� In therest of this section� we discuss some common sources of errors� �Wehasten to add that types of errors in proofs are as numerous as grainsof sand� and by no means do we want to attempt any classi�cation�
One quite frequent situation is where the student doesn�t under�stand the problem correctly� There may be subtleties in the problem�sformulation which are easy to overlook� and sometimes a misunder�standing isn�t the student�s fault at all� since the author of the prob�lem might very well have failed to see some double meaning� The onlydefense against this kind of misunderstanding is to pay the utmostattention to reading and understanding a problem before trying tosolve it� Do a preliminary check� does the problem make sense in theway you understand it� Does it have a suspiciously trivial solution�Could there be another meaning�
With the current abundance of calculators and computers� errors aresometimes caused by the uncritical use of such equipment� Asked howmany zeros does the decimal notation of the number � � � � �������� � ���end with� a student answered ��� because a pocket calculator with an��digit display shows that � � � �� ��� �� ��Well� a more sophisticatedcalculator or computer programmed to calculate with integers with ar�bitrarily many digits would solve this problem correctly and calculatethat
�������������� ��� ����������� ����� ���������������������
with �� trailing zeros� Several software systems can even routinely solvesuch problems as �nding a formula for the sum ������������������� � ��n��n� or for the number of binary trees on n vertices see Section � ���But even programmers of such systems can make mistakes and so it�sbetter to double�check such results� Moreover� the capabilities of thesesystems are very limited� arti�cial intelligence researchers will have tomake enormous progress before they can produce computers that candiscover and prove a formula for the number of trailing zeros of n�� orsolve a signi�cant proportion of the exercises in this book� say�
Next� we consider the situation where a proof has been writtendown but it has a aw� although its author believes it to be satisfac�tory�
� Introduction and basic concepts
In principle� proofs can be written down in such detail and in sucha formal manner that they can be checked automatically by a com�puter� If such a completely detailed and formalized proof is wrong�some step has to be clearly false� but the catch is that formalizingproofs completely is very laborious and impractical� All textbookproofs and problem solutions are presented somewhat informally�
While some informality may be necessary for a reasonable pre�sentation of a proof� it may also help to hide errors� Nevertheless�a good rule for writing and checking proofs is that every statement
in a correct proof should be literally true� Errors can often be de�tected by isolating a speci�c false statement in the proof� a mistakein calculation� or a statement that makes no sense ��Let ��� �� be two
arbitrary lines in the ��dimensional space� and let � be a plane contain�
ing both of them� � � � etc�� Once detected and brought out into thelight� such errors become obvious to �almost everyone� Still� theyare frequent� If� while trying to come up with a proof� one discoversan idea seemingly leading to a solution and shouts �This must beIT��� caution is usually swept aside and one is willing to write downthe most blatant untruths� �Unfortunately� the �rst idea that comesto mind is often nonsense� rather than �it�� at least as far as theauthors� own experience with problem solving goes�
A particularly frequent mistake� common perhaps to all mathe�maticians of the world� is a case omission� The proof works for someobjects it should deal with� but it fails in some cases the author over�looked� Such a case analysis is mostly problem speci�c� but one keepsencountering variations on favorite themes� Dividing an equation byx� y is only allowed for x � y� and the x � y case must be treatedseparately� An intersection of two lines in the plane can only be usedin a proof if the lines are not parallel� Deducing a� � b� from a � bmay be invalid if we know nothing about the sign of a and b� and soon and so on�
Many proofs created by beginners are wrong because of a confusedapplication of theorems� Something seems to follow from a theorempresented in class or in a textbook� say� but in reality the theoremsays something slightly di�erent� or some of its assumptions don�thold� Since we have covered no theorems worth mentioning so far� letus give an arti�cial geometric example� �Since ABC is an isosceles
triangle with the sides adjacent to A having equal length� we have
jABj� % jACj� � jBCj� by the theorem of Pythagoras�� Well� wasn�t
��� Mathematical induction and other proofs ��
there something about a right angle in Pythagoras� theorem�A rich source of errors and misunderstandings is relying on un�
proved statements�
Many proofs� including correct and even textbook ones� contain un�proved statements intentionally� marked by clauses like �obviously� � � ��In an honest proof� the meaning of such clauses should ideally be �I�the author of this proof� can see how to prove this rigorously� and sinceI consider this simple enough� I trust that you� my reader� can also �llin all the details without too much e�ort�� Of course� in many mathe�matical papers� the reader�s impression about the author�s thinking ismore in the spirit of �I can see it somehow since I�ve been working onthis problem for years� and if you can�t it�s your problem�� Hence omit�ting parts of proofs that are �clear� is a highly delicate social task� andone should always be very careful with it� Also� students shouldn�t besurprised if their teacher insists that such an �obvious� part be provedin detail� After all� what would be a better hiding place for errors in aproof than in the parts that are missing�
A more serious problem concerns parts of a proof that are omittedunconsciously� Most often� the statement whose proof is missing isnot even formulated explicitly�� For a teacher� it may be a very chal�lenging task to convince the proof�s author that something is wrongwith the proof� especially when the unproved statement is actuallytrue�
One particular type of incomplete proof� fairly typical of students�proofs in discrete mathematics� could be labeled as mistaking the par�ticular for the general� To give an example� let us consider the followingMathematical Olympiad problem�
����� Problem� Let n � � be an integer� Let M be a set of closedintervals� Suppose that the endpoints u� v of each interval �u� v� � Mare natural numbers satisfying � � u � v � n� and� moreover� for anytwo distinct intervals I� I � �M � one of the following possibilities occurs�I � I � � � or I � I �� or I � � I i�e� two intervals must not partiallyoverlap� Prove that jM j � n� ��An insu�cient proof attempt� In order to construct an M as largeas possible� we �rst insert as many unit�length intervals as possible� as inthe following �gure�
� � ��� � �
Even proofs by the greatest mathematicians of the past su�er from suchincompleteness� partly because the notion of a proof has been developing overthe ages �towards more rigor� that is��
�� Introduction and basic concepts
These bn��c intervals are all disjoint� Now any other interval in M mustcontain at least two of these unit intervals �or� for n odd� possibly thelast unit interval plus the point that remains� Hence� to get the maximumnumber of intervals� we put in the next layer� of shortest possible intervals�as illustrated below�
� � ��� � �
We continue in this manner� adding one layer after another� until we �nallyadd the last layer consisting of the whole interval ��� n��
� � ��� � �
It remains to show that the set M created in this way has at most n � �intervals� We note that every interval I in the kth layer contains a point ofthe form i� �
� � � � i � n��� that was not contained in any interval of theprevious layers� because the space between the two intervals in the previouslayer was not covered before adding the kth layer� Therefore� jM j � n� �as claimed� �
This �proof� looks quite clever after all� the way of counting theintervals in the particular M constructed in the proof is quite elegant�So what�s wrong with it� Well� we have shown that one particular Msatis�es jM j � n � �� The argument tries to make the impression ofshowing that this particular M is the worst possible case� i�e� that noother M may have more intervals� but in reality it doesn�t prove any�thing like that� For instance� the �rst step seems to argue that an Mwith the maximum possible number of intervals should contain bn��cunit�length intervals� But this is not true� as is witnessed byM � f��� ������ ��� ��� ��� � � � � ��� n�g� Saving the �proof� above by justifying its varioussteps seems more di�cult than �nding another� correct� proof� Althoughthe demonstrated �proof� contains some useful hints the counting ideaat the end of the proof can in fact be made to work for any M� it�sstill quite far from a valid solution�The basic scheme of this �proof�� apparently a very tempting one�
says �this object X must be the worst one�� and then proves that thisparticular X is OK� But the claim that nothing can be worse than X isnot substantiated although it usually looks plausible that by construct�ing this X � we �do the worst possible thing� concerning the statementbeing proved�Another variation of �mistaking the particular for the general� often
appears in proofs by induction� and is shown in several examples inSections ��� and ����
��� Mathematical induction and other proofs ��
Exercises
�� Prove the following formulas by mathematical induction�
a � � � � � � � � �� n � nn� ���
bPn
i�� i � �i � n� ��n�� � ��
�� The numbers F�� F�� F�� � � � are de�ned as follows this is a de�nitionby mathematical induction� by the way� F� � � F� � �� Fn�� �Fn�� � Fn for n � � �� �� � � �� Prove that for any n we haveFn � � �
p���n�� see also Section � ���
�� a Let us draw n lines in the plane in such a way that no two areparallel and no three intersect in a common point� Prove that theplane is divided into exactly nn� ��� � � parts by the lines�
b �Similarly� consider n planes in the ��dimensional space in gen�eral position no two are parallel� any three have exactly one point incommon� and no four have a common point� What is the number ofregions into which these planes partition the space�
�� Prove de Moivre�s theorem by induction� cos��i sin�n � cosn��i sinn�� Here i is the imaginary unit�
�� In ancient Egypt� fractions were written as sums of fractions with nu�merator �� For instance� �
� ��� �
��� � Consider the following algorithm
for writing a fraction mn in this form � � m � n� write the fraction
�dn�me � calculate the fraction
mn � �
dn�me � and if it is nonzero repeat thesame step� Prove that this algorithm always �nishes in a �nite numberof steps�
�� �Consider a �n � �n chessboard with one arbitrarily chosen squareremoved� as in the following picture for n � ��
Prove that any such chessboard can be tiled without gaps or overlapsby L�shapes consisting of � squares each�
�� Let n � be a natural number� We consider the following game� Twoplayers write a sequence of s and �s� They start with an empty lineand alternate their moves� In each move� a player writes or � tothe end of the current sequence� A player loses if his digit completesa block of n consecutive digits that repeats itself in the sequence for
�� Introduction and basic concepts
the second time the two occurrences of the block may overlap� Forinstance� for n � �� a sequence produced by such a game may lookas follows� � �� � ���� �� the second player lost by the lastmove because �� is repeated�
a Prove that the game always �nishes after �nitely many steps�
b �Suppose that n is odd� Prove that the second player the one whomakes the second move has a winning strategy�
c �Show that for n � �� the �rst player has a winning strategy�Unsolved question� Can you determine who has a winning strategy forsome even n � ��
�� �On an in�nite sheet of white graph paper a paper with a squaregrid� n squares are colored black� At moments t � �� �� � � �� squaresare recolored according to the following rule� each square gets the coloroccurring at least twice in the triple formed by this square� its topneighbor� and its right neighbor� Prove that after the moment t � n�all squares are white�
�� At time � a particle resides at the point on the real line� Within �second� it divides into � particles that �y in opposite directions andstop at distance � from the original particle� Within the next second�each of these particles again divides into � particles �ying in oppositedirections and stopping at distance � from the point of division� and soon� Whenever particles meet they annihilate leaving nothing behind�How many particles will there be at time ��� � ��
� � �Let M � R be a set of real numbers� such that any nonempty subsetof M has a smallest number and also a largest number� Prove that Mis necessarily �nite�
��� We will prove the following statement by mathematical induction� Let��� ��� � � � � �n be n � distinct lines in the plane� no two of which areparallel� Then all these lines have a point in common�
�� For n � � the statement is true� since any � nonparallel lines intersect�
� Let the statement hold for n � n�� and let us have n � n� � �lines ��� � � � � �n as in the statement� By the inductive hypothesis� all theselines but the last one �i�e� the lines ��� ��� � � � � �n�� have some pointin common� let us denote this point by x� Similarly the n � � lines��� ��� � � � � �n��� �n have a point in common� let us denote it by y� Theline �� lies in both groups� so it contains both x and y� The same is truefor the line �n��� Now �� and �n�� intersect at a single point only� andso we must have x � y� Therefore all the lines ��� � � � � �n have a point incommon� namely the point x�
Something must be wrong� What is it�
��� Functions ��
��� Let n�� n�� � � � � nk be natural numbers� each of them at least �� and letn��n��� � ��nk � n� Prove that n���n
���� � ��n�k � n�k����k���
�Solution�� In order to makePk
i�� n�i as large as possible� we must set
all the ni but one to �� The remaining one is therefore n� k � �� and inthis case the sum of squares is n� k � �� � k � ��Why isn�t this a valid proof� �Give a correct proof�
��� �Give a correct proof for Problem ������
��� �Let n � � and k be given natural numbers� Let I�� I�� � � � � Im beclosed intervals not necessarily all distinct� such that for each intervalIj � �uj � vj �� uj and vj are natural numbers with � � uj � vj � n�and� moreover� no number is contained in more than k of the intervalsI�� � � � � Im� What is the largest possible value of m�
��� FunctionsThe notion of a function is a basic one in mathematics� It took a longtime for today�s view of functions to emerge� For instance� aroundthe time when di�erential calculus was invented� only real or com�plex functions were considered� and an �honest� function had to beexpressed by some formula� such as fx � x� � �� fx �
psinx���
fx �R x� sin t�tdt� fx �
P�n��x
n�n�� and so on� By today�s stan�dards� a real function may assign to each real number an arbitrary realnumber without any restrictions whatsoever� but this is a relativelyrecent invention�
Let X and Y be some quite arbitrary sets� Intuitively� a function f is�something� assigning a unique element of Y to each element of X�To depict a function� we can draw the sets X and Y � and draw anarrow from each element x � X to the element y � Y assigned to it�
�
�
�
��
�
X Y
Note that each element of X must have exactly one outgoing ar�row� while the elements of Y may have none� one� or several ingoingarrows�
Instead of saying that a function is �something�� it is better tode�ne it using objects we already know� namely sets and orderedpairs�
�� Introduction and basic concepts
����� De�nition� A function f from a set X into a set Y is a set
of ordered pairs �x� y with x � X and y � Y �in other words� a
subset of the Cartesian product X Y �� such that for any x � X� fcontains exactly one pair with �rst component x�
Of course� an ordered pair �x� y being in f means just that theelement x is assigned the element y� We then write y � f�x� andwe also say that f maps x to y or that y is the image of x�
For instance� the function depicted in the above �gure consists ofthe ordered pairs �� �� �� �� ��� �� and ��� ��
A function� as a subset of the Cartesian productX�Y � is also drawnusing a graph� We depict the Cartesian product as in Fig� ���� and thenwe mark the ordered pairs belonging to the function� This is perhaps themost usual way used in high school or in calculus� The following �gureshows a graph of the function f �R� R given by fx � x� � x� ��
�� �
�
�
The fact that f is a function from a set X into a set Y is writtenas follows�
f �X � Y �
And the fact that the function f assigns some element y to an ele�ment x can also be written
f �x �� y�
We could simply write y � fx instead� So why this new notation�The symbol �� is advantageous when we want to speak about somefunction without naming it� Those who have programmed in LISP�Mathematica� or a few other programming languages might recall theexistence of unnamed functions in these languages� For instance� it isnot really correct to say �consider the function x��� since we do not saywhat the variable is� In this particular case� one can be reasonably surethat we mean the function assigning x� to each real number x� but if wesay �consider the function zy���z�y�� it is not clear whether we meanthe dependence on y� on z� or on both� By writing y �� zy� � �z�y� weindicate that we want to study the dependence on y� treating z as someparameter�
��� Functions ��
Instead of �function�� the words �mapping� or �map� are used withthe same meaning��
Sometimes we also write f�X for the set ff�x� x � Xg �the setof those elements of Y that are images of something� Also otherterms are usually introduced for functions� For example� X is calledthe domain and Y is the range� etc�� but here we try to keep theterminology and formalism to a minimum�
We de�nitely need to mention that functions can be composed�
����� De�nition �Composition of functions�� If f �X � Y and
g�Y � Z are functions� we can de�ne a new function h�X � Z by
h�x � g�f�x
for each x � X� In words� to �nd the value of h�x� we �rst apply fto x and then we apply g to the result�
The function h �check that h is indeed a function� is called the
composition of the functions g and f and it is denoted by g � f � We
thus have �g � f
��x � g�f�x
for each x � X�
The composition of functions is associative but not commutative�For example� if g � f is well de�ned� f � g need not be� In order thattwo functions can be composed� the �middle set� must be the same�
Composing functions can get quite exciting� For example� considerthe mapping f �R� � R� i�e� mapping the plane into itself given by
f � x� y ���sinax � b sinay� sincx � d sincy
�
with a � ��������� b � �������� c � � �������� d � �������� Exceptfor the rather hairy constants� this doesn�t look like a very complicatedfunction� But if one takes the initial point p � ��� �� and plotsthe �rst several hundred thousand or million points of the sequence p�fp� ffp� fffp�� � � � a picture like Fig� ��� emerges�� This is
�In some branches of mathematics� the word function is reserved for func�tion into the set of real or complex numbers� and the word mapping is used forfunctions into arbitrary sets� For us� the words function and mapping willbe synonymous�
To be quite honest� the way such pictures are generated by a computer isactually by iterating an approximation to the mapping given by the formula�because of limited numerical precision�
�� Introduction and basic concepts
Fig� ��� The �King�s Dream� fractal formula taken from the book by
C� Pickover� Chaos in Wonderland� St Martin�s Press� New York �����
one of the innumerable species of the so�called fractals� There seemsto be no universally accepted mathematical de�nition of a fractal� butfractals are generally understood as complicated point sets de�ned byiterations of relatively simple mappings� The reader can �nd colorfuland more sophisticated pictures of various fractals in many books onthe subject or download them from the Internet� Fractals can be notonly pleasant to the eye and suitable for killing an unlimited amount oftime by playing with them on a personal computer but also importantfor describing various phenomena in nature�
After this detour� let us return to the basic de�nitions concerningfunctions�
����� De�nition �Important special types of functions�� A
function f �X � Y is called
� a one�to�one function if x � y implies f�x � f�y�
� a function onto if for every y � Y there exists x � X satisfying
f�x � y� and
� a bijective function� or bijection� if f is one�to�one and onto�
A one�to�one function is also called an injective function or aninjection� and a function onto is also called a surjective function ora surjection�
��� Functions ��
In a pictorial representation of functions by arrows� these typesof functions can be recognized as follows�
� for a one�to�one function� each point y � Y has at most one
ingoing arrow�
� for a function onto� each point y � Y has at least one ingoingarrow� and
� for a bijection� each point y � Y has exactly one ingoing arrow�
The fact that a function f �X � Y is one�to�one is sometimes ex�pressed by the notation
f �X��Y�
The �� symbol is a combination of the inclusion sign � with the map�ping arrow �� Why� If f �X��Y is an injective mapping� then the setZ � fX can be regarded as a �copy� of the set X within Y since fconsidered as a map X � Z is a bijection� and so an injective map�ping f �X��Y can be thought of as a �generalized inclusion� of X inY � This point can probably be best appreciated in more abstract andmore advanced parts of mathematics like topology or algebra�There are also symbols for functions onto and for bijections� but
these are still much less standard in the literature than the symbol foran injective function� so we do not introduce them�
Since we will be interested in counting objects� bijections will beespecially signi�cant for us� for the following reason� if X and Y are setsand there exists a bijection f �X � Y � then X and Y have the samenumber of elements� Let us give a simple example of using a bijectionfor counting more sophisticated ones come later�
����� Example� How many ��digit sequences consisting of digits through � are there� How many of them contain an even number ofodd digits�
Solution� The answer to the �rst question is � �� One easy way ofseeing this is to note that each ��digit sequence can be read as thedecimal notation of an integer number between and � � � �� andconversely� each such integer can be written in decimal notation and� ifnecessary� padded with zeros on the left to produce an ��digit sequence�This de�nes a bijection between the set f � �� � � � � � � � �g and the setof all ��digit sequences�Well� this bijection was perhaps too simple or� rather� too custom�
ary to impress anyone� What about the ��digit sequences with an evennumber of odd digits� Let E be the set of all these sequences E for�even�� and let O be the remaining ones� i�e� those with an odd num�ber of odd digits� Consider any sequence s � E� and de�ne anothersequence� fs� by changing the �rst digit of s� is changed to �� � to��� � � � � to �� and � to � It is easy to check that the modi�ed sequence
� Introduction and basic concepts
fs has an odd number of odd digits and hence f is a mapping fromE to O� From two di�erent sequences s� s� � E� we cannot get the samesequence by the described modi�cation� so f is one�to�one� And anysequence t � O is obtained as fs for some s � E� i�e� s arises fromt by changing the �rst digit �back�� by replacing � by � � by ��� � � �� by �� and by �� Therefore� f is a bijection and jEj � jOj� SincejEj� jOj � � �� we �nally have jEj � � � � � �
In the following proposition� we prove some simple properties offunctions�
Proposition� Let f �X � Y and g�Y � Z be functions� Then
�i� If f� g are onetoone� then g f is also a onetoone function�
�ii� If f� g are functions onto� then g f is also a function onto�
�iii� If f� g are bijective functions� then g f is a bijection as well�
�iv� For any function f �X � Y there exist a set Z� a onetoone functionh�Z��Y � and a function onto g�X � Z� such that f � h g� �So anyfunction can be written as a composition of a onetoone functionand a function onto��
Proof� Parts i� ii� iii are obtained by direct veri�cation from thede�nition� As an example� let us prove ii�We choose z � Z� and we are looking for an x � X satisfying
g fx � z� Since g is a function onto� there exists a y � Y such thatgy � z� And since f is a function onto� there exists an x � X withfx � y� Such an x is the desired element satisfying g fx � z�The most interesting part is iv� Let Z � fX so Z � Y � We
de�ne mappings g�X � Z and h�Z � Y as follows�
gx � fx for x � Xhz � z for z � Z�
Clearly g is a function onto� h is one�to�one� and f � h g� �
Finishing the remaining parts of the proof may be a good exercisefor understanding the notions covered in this section�
Inverse function� If f �X � Y is a bijection� we can de�ne afunction g�Y � X by setting g�y � x if x is the unique elementof X with y � f�x� This g is called the inverse function of f � andit is commonly denoted by f��� Pictorially� the inverse function isobtained by reversing all the arrows� Another equivalent de�nitionof the inverse function is given in Exercise �� It may look more com�plicated� but from a certain �higher� mathematical point of view itis better�
��� Functions ��
Exercises
�� Show that if X is a �nite set� then a function f �X � X is one�to�oneif and only if it is onto�
�� Find an example of�
a A one�to�one function f �N��N which is not onto�
b A function f �N� N which is onto but not one�to�one�
�� Decide which of the following functions Z� Z are injective and whichare surjective� x �� � � x� x �� � � x�� x �� � � x�� x �� � � x� � x��Does anything in the answer change if we consider them as functionsR � R� You may want to sketch their graphs and�or use someelementary calculus methods�
�� For a setX � let idX �X � X denote the function de�ned by idXx � xfor all x � X the identity function� Let f �X � Y be some function�Prove�
a A function g�Y � X such that g f � idX exists if and only if fis one�to�one�
b A function g�Y � X such that f g � idY exists if and only if fis onto�
c A function g�Y � X such that both f g � idY and g f � idXexist if and only if f is a bijection�
d If f �X � Y is a bijection� then the following three conditions areequivalent for a function g�Y � X �
i g � f���
ii g f � idX � andiii f g � idY �
�� a If g f is an onto function� does g have to be onto� Does f haveto be onto�
b If g f is a one�to�one function� does g have to be one�to�one� Doesf have to be one�to�one�
�� Prove that the following two statements about a function f �X � Yare equivalent X and Y are some arbitrary sets�
i f is one�to�one�
ii For any set Z and any two distinct functions g��Z � X andg��Z � X � the composed functions f g� and f g� are also distinct�First� make sure you understand what it means that two functionsare equal and what it means that they are distinct�
�� In everyday mathematics� the number of elements of a set is under�stood in an intuitive sense and no de�nition is usually given� In thelogical foundations of mathematics� however� the number of elements
�� Introduction and basic concepts
is de�ned via bijections� jX j � n means that there exists a bijectionfrom X to the set f�� �� � � � � ng� Also other� alternative de�nitions ofset size exist but we will consider only this one here�
a Prove that if X and Y have the same size according to this de�ni�tion� then there exists a bijection from X to Y �
b Prove that if X has size n according to this de�nition� and thereexists a bijection from X to Y � then Y has size n too�
c �Prove that a set cannot have two di�erent sizes m and n� m �� n�according to this de�nition� Be careful not to use the intuitive notionof �size� but only the de�nition via bijections� Proceed by induction�
��� RelationsIt is remarkable how many mathematical notions can be expressed usingsets and various set�theoretic constructions� It is not only remarkablebut also surprising� since set theory� and even the notion of a set itself�are notions which appeared in mathematics relatively recently� and some� years ago� set theory was rejected even by some prominent mathe�maticians� Today� set theory has entered the mathematical vocabularyand it has become the language of all mathematics and mathemati�cians� a language which helps to understand mathematics� with all itsdiversity� as a whole with common foundations�We will show how more complicated mathematical notions can be
built using the simplest set�theoretical tools� The key notion of a re�lation��� which we now introduce� is a common generalization of suchdiverse notions as equivalence� function� and ordering�
����� De�nition� A relation is a set of ordered pairs��� If X and
Y are sets� any subset of the Cartesian product X Y is called a
relation between X and Y � The most important case is X � Y �then we speak of a relation on X� which is thus an arbitrary subset
R � X X�
If an ordered pair �x� y belongs to a relation R� i�e� �x� y � R�we say that x and y are related by R� and we also write xRy�
We have already seen an object which was a subset of a Cartesianproduct� namely a function� Indeed� a function is a special type ofrelation� where we require that any x � X is related to precisely one
��As a mathematical object� you know relation as a word in common lan�guage�
��In more detail� we could say a binary relation �since pairs of elements arebeing related�� Sometimes also n�ary relations are considered for n �� ��
�� Relations ��
� � � �
�
�
�
�
Fig� ��� A graphic presentation of the relation R � f�� �� �� �� �� ���� �� �� �g on the set f�� �� �� �g�
y � Y � In a general relation� an x � X can be related to severalelements of Y � or also to none�
Many symbols well known to the reader can be interpreted as rela�tions in this sense� For instance� � equality and non�strict inequal�ity are both relations on the set N of all natural numbers� The �rstone consists of the pairs �� �� �� �� �� �� � � �� the second one of thepairs �� �� �� �� �� �� �� �� �� �� �� �� �� �� � � �� We could thusalso write �� � � instead of the usual � �� which we usually don�tdo� however� Note that we had to specify the set on which the relation� say� is considered� as a relation on R it would be a quite di�erentset of ordered pairs�Many interesting �real life� examples of relations come from various
kinds of relationships among people� e�g� �to be the mother of�� �to bethe father of�� �to be a cousin of� are relations on the set of all people�usually well de�ned although not always easy to determine�
A relation R on a set X can be captured pictorially in �at leasttwo quite di�erent ways� The �rst way is illustrated in Fig� ���� Thelittle squares correspond to ordered pairs in the Cartesian product�and for pairs belonging to the relation we have shaded the corre�sponding squares� This kind of picture emphasizes the de�nition ofa relation on X and it captures its �overall shape��
This �gure is also very close in spirit to an alternative way of de�scribing a relation on a set X using the notion of a matrix��� If R isa relation on some n�element set X � fx�� x�� � � � � xng then R is com�
��An n � m matrix is a rectangular table of numbers with n rows and mcolumns� Any reader who hasn�t met matrices yet can consult the Appendix forthe de�nitions and basic facts� or� preferably� take a course of linear algebra orrefer to a good textbook�
�� Introduction and basic concepts
pletely described by an n� n matrix A � aij� where
aij � � if xi� xj � Raij � if xi� xj �� R�
The matrix A is called the adjacency matrix of the relation R� Forinstance� for the relation in Fig� ���� the corresponding adjacency matrixwould be �
BB � � � � �
CCA �
Note that this matrix is turned by � degrees compared to Fig� ���� Thisis because� for a matrix element� the �rst index is the number of a rowand the second index is the number of a column� while for Cartesiancoordinates it is customary for the �rst coordinate to determine thehorizontal position and the second coordinate the vertical position�The adjacency matrix is one possible computer representation of a
relation on a �nite set�
Another picture of the same relation as in Fig� ��� is shown below�
� �� �
Here the dots correspond to elements of the set X� The fact thata given ordered pair �x� y belongs to the relation R is marked bydrawing an arrow from x to y�
x y
and� in the case x � y� by a loop�
x
A relation between X and Y can be depicted in a similar way�
rrrr�
�
�
�
X rrr
�
�
�
�
YR�
QQQQQQQs���
������
��������
�� Relations ��
This way was suggested for drawing functions in Section ����
Composition of relations� Let X�Y� Z be sets� let R � X � Y bea relation between X and Y � and let S � Y � Z be a relation betweenY and Z� The composition of the relations R and S is the relationT � X � Z de�ned as follows� for given x � X and z � Z� xTz holdsif and only if there exists some y � Y such that xRy and ySz� Thecomposition of relations R and S is usually denoted by R S�The composition of relations can be nicely illustrated using a draw�
ing with arrows� In the following �gure�
rrrr�
�
�
�
X rrr
�
�
�
�
YR�
QQQQQQQs���
������
��������
rrrrrS
Z
����
����
�����
����
PPPPPPPq��������
�
�
�
�a pair x� z is in the relation R S whenever one can get from x to zalong the arrows i�e� via some y � Y �Have you noticed� Relations are composed in the same way as func�
tions� but the notation is unfortunately di�erent� For relations it is cus�tomary to write the composition �from left to right�� and for functionsit is usually written �from right to left�� So if f �X � Y and g�Y � Zare functions� their composition is written g f � but if we understoodthem as relations� we would write f g for the same thing� Both ways ofnotation have their reasons� such a notation has been established his�torically� and probably there is no point in trying to change it� In thistext� we will talk almost exclusively about composing functions�Similarly as for functions� the composition is not de�ned for arbi�
trary two relations� In order to compose relations� they must have the�middle� set in common which was denoted by Y in the de�nition�In particular� it may happen that R S is de�ned while S R makesno sense� However� if both R and S are relations on the same set X �their composition is always well de�ned� But also in this case the resultof composing relations depends on the order� and R S is in generaldi�erent from S R�see Exercise ��
Exercises
�� Describe the relation R R� if R stands fora the equality relation ��� on the set N of all natural numbers�
b the relation �less than or equal� ��� on N�
�� Introduction and basic concepts
c the relation �strictly less� ��� on N�
d the relation �strictly less� ��� on the set R of all real numbers�
�� Find relations R� S on some set X such that R S �� S R��� For a relation R on a set X we de�ne the symbol Rn by induction�
R� � R� Rn�� � R Rn�
a Prove that if X is �nite and R is a relation on it� then there existr� s � N� r � s� such that Rr � Rs�
b Find a relation R on a �nite set such that Rn �� Rn�� for everyn � N�c Show that if X is in�nite� the claim a need not hold i�e� a relationR may exist such that all the relations Rn� n � N� are distinct�
�� a Let X � fx�� x�� � � � � xng and Y � fy�� y�� � � � � ymg be �nite sets�and let R � X � Y be a relation� Generalize the de�nition of theadjacency matrix of a relation to this case�
b �Let X�Y� Z be �nite sets� let R � X � Y and S � Y � Z be re�lations� and let AR and AS be their adjacency matrices� respectively�If you have de�ned the adjacency matrix in a properly� the matrixproduct ARAS should be well de�ned� Discover and describe the con�nection of the composed relation R S to the matrix product ARAS �
�� Prove the associativity of composing relations� if R�S� T are relationssuch that R S T is well de�ned� then also R S T is well de�nedand equals R S T �
��� Equivalences
Besides the functions� equivalences are another important specialtype of relations� Informally� an equivalence on a set X is a rela�tion describing which pairs of elements of X are �of the same type�in some sense� For instance� let X be the set of all triangles in theplane� By saying that two triangles are related if and only if theyare congruent �i�e� one can be transformed into the other by transla�tion and rotation� we have de�ned one equivalence on X� Anotherequivalence is de�ned by relating all pairs of similar triangles �twotriangles are similar if one can be obtained from the other one bytranslation� rotation� and scaling� in other words� if their correspond�ing angles are the same� And a third equivalence arises by sayingthat each triangle is only related to itself�
These are three particular examples of equivalence relations� andthe reader may look forward to many more examples later on� In
��� Equivalences ��
general� in order to be called an equivalence� a relation must sat�isfy three conditions� These conditions are so useful that they eachdeserve a name�
����� De�nition� We say that a relation R on a set X is
� re exive if xRx for every x � X�
� symmetric if xRy implies yRx� for all x� y � X�
� transitive if xRy and yRz imply xRz� for all x� y� z � X�
In a drawing like that in Fig� ���� a re exive relation is one con�taining all squares on the diagonal �drawn by a dotted line� In draw�ing using arrows� a re exive relation has loops at all points�
For a symmetric relation� a picture of the type in Fig� ��� hasthe diagonal as an axis of symmetry� In a picture using arrows� thearrows between two points always go in both directions�
x y
The condition of transitivity can be well explained using arrows�If there are arrows x� y and y � z� then the x� z arrow is presentas well�
x y z
����� De�nition� We say that a relation R on X is an equivalenceon X if it is re�exive� symmetric� and transitive�
�You may want to contemplate for a while why these propertiesare natural for a relation that should express something like �beingof the same type�� The notion of equivalence is a common gener�alization of notions expressing identity� isomorphism� similarity� etc�Relations of equivalence are often denoted by symbols like �� �� ���� ��� and so on�
Although an equivalence R on a set X is a special type of relationand we can thus depict it by either of the above methods� more oftena picture similar to the one below is used�
������
EEEEEE�
������
��
�
�
�
�
�� Introduction and basic concepts
The key to this type of drawing is the following notion of equivalenceclass� Let R be an equivalence on a set X and let x be an elementof X� By the symbol R�x�� we denote the set of all elements y � Xthat are equivalent to x� in symbols� R�x� � fy � X� xRyg� R�x� iscalled the equivalence class of R determined by x�
����� Proposition� For any equivalence R on X� we have
�i� R�x� is nonempty for every x � X�
�ii� For any two elements x� y � X� either R�x� � R�y� or R�x� R�y� � ��
�iii� The equivalence classes determine the relation R uniquely�
Before we start proving this� we should explain the meaning of�iii� It means the following� if R and S are two equivalences on Xand if the equality R�x� � S�x� holds for every element x � X� thenR � S�
Proof� The proof is simple using the three requirements in thede�nition of equivalence�
�i The set R�x� always contains x since R is a re exive relation�
�ii Let x� y be two elements� We distinguish two cases�
�a If xRy� then we prove R�x� � R�y� �rst� Indeed� if z � R�x��then we also know that zRx �by symmetry of R and there�fore zRy �by transitivity of R� Thus also z � R�y�� By usingsymmetry again� we get that xRy implies R�x� � R�y��
�b Suppose that xRy doesn�t hold� We show that R�x�R�y� ��� We proceed by contradiction� Suppose that there existsz � R�x� R�y�� Then xRz and zRy �by symmetry of R�and so xRy �by transitivity of R� which is a contradiction�
�iii This part is obvious� since the equivalence classes determine Ras follows�
xRy if and only if fx� yg � R�x��
�
The above proposition explains the preceding picture� It guaran�tees that the equivalence classes form a partition of the set X� that is�they are pairwise disjoint subsets of X whose union is the whole X�Conversely� any partition of X determines exactly one equivalenceon X� That is� there exists a bijective mapping of the set of all equiv�alences on X onto the set of all partitions of X�
��� Equivalences ��
Exercises
�� Formulate the conditions for re�exivity of a relation� for symmetry ofa relation� and for its transitivity using the adjacency matrix of therelation�
�� Prove that a relation R is transitive if and only if R R � R�
�� a Prove that for any relation R� the relation T � R�R R�R R R � � � � the union of all multiple compositions of R is transitive�b Prove that any transitive relation containing R as a subset alsocontains T �
c Prove that if jX j � n� then T � R � R R � � � � � R R � � � R� �z �n����
�
Remark� The relation T as in a� b is the smallest transitive relationcontaining R� and it is called the transitive closure of R�
�� Let R and S be arbitrary equivalences on a set X � Decide which ofthe following relations are necessarily also equivalences if yes� prove�if not� give a counterexample�
a R � Sb R � Sc R n Sd R S�
�� a Suppose that R is a transitive relation on the set Z of all integers�and we know that for any two integers a� b � Z� if ja � bj � � thenaRb� Is every R satisfying these conditions necessarily an equivalence�Note that a pair of elements can perhaps be in R even if it is notenforced by the given conditions�
b Suppose that R is a transitive relation on Z� and we know that forany two integers a� b � Z� if ja� bj � f�� �g then aRb� Is R necessarilyan equivalence�
�� Call an equivalence � on the set Z the integers a congruence if thefollowing condition holds for all a� x� y � Z� if x � y then also a� x �a� y�
a Let q be a nonzero integer� De�ne a relation �q on Z by lettingx �q y if and only if q divides x � y� Check that �q is a congruenceaccording to the above de�nition�
b �Prove that any congruence on Z is either of the form �q for someq or the diagonal relation fx� x� x � Zg�c Suppose we replaced the condition �a�x � a�y� in the de�nitionof a congruence by �ax � ay�� Would the claim in a remain true forthis kind of �multiplicative congruence�� �And how about the claimin b�
� Introduction and basic concepts
��� Ordered setsThe reader will certainly be familiar with the ordering of naturalnumbers and of other number domains by magnitude �the �usual�ordering of numbers� In mathematics� such an ordering is consideredas a special type of a relation� i�e� a set of pairs of numbers� In thecase just mentioned� this relation is usually denoted by the symbol��� ��less than or equal�� Various orderings can be de�ned on othersets too� such as the set of all words in some language� and one setcan be ordered in many di�erent and perhaps exotic ways�
Before introducing the general notion of an ordered set� we de�nean auxiliary notion� A relation R on a set X is called antisymmet�
ric�� if xRy and yRx imply that x � y� for all x� y � X� Whendepicting a relation by arrows� the following situation is forbiddenin an antisymmetric relation�
x y
���� De�nition� An ordering on a set X is any relation on X that
is re�exive� antisymmetric� and transitive� An ordered set is a pair
�X�R� where X is a set and R is an ordering on X�
Note the formal similarity of this de�nition to the de�nition of anequivalence� The de�nitions are almost the same� �only� the symmetryhas been replaced by antisymmetry� Yet equivalences and orderings arevery di�erent concepts�
For orderings� the symbols � or � are commonly used� The �rstof them is useful� e�g� when we want to speak of some other orderingof the set of natural numbers than the usual ordering by magnitude�or if we consider some arbitrary ordering on a general set�
If we have some ordering �� we de�ne a derived relation of �strictinequality�� �� as follows� a � b if and only if a � b and a � b�Further we can introduce the �reverse inequality� �� by letting a � bif and only if b � a�
Examples� We have already mentioned several examples of orderedsetsthese were �N��� �R��� and similar ones� where � of coursedenotes the usual ordering� formally understood as a relation�
��Sometimes this is called weakly antisymmetric� while for a strongly antisym�
metric relation xRy and yRx never happen at the same time� i�e� xRx is alsoexcluded�
��� Ordered sets ��
As is easy to check� if R is an ordering on a set X � and Y � X issome subset of X � the relation R � Y � the restriction of R on Y isan ordering on Y � Intuitively� we order the elements of Y in the sameway as before but we forget the others� This yields further examplesof ordered sets� namely various subsets of real numbers with the usualordering�
Linear orderings� The examples discussed so far have a signi�cantfeature in common� any two elements of the underlying set can becompared� in other words� for any two distinct elements x and yeither x � y or y � x holds� This property is not a part of thede�nition of an ordering� and orderings having it are called linear
orderings �sometimes the term total ordering is used with the samemeaning�
Other examples of orderings� What do orderings which arenot linear look like� For example� on any set X� we may de�ne arelation ' in which each element x is in relation with itself only� i�e�' � f�x� x� x � Xg� It is easily checked that this relation satis�esthe de�nition of an ordering� but this is a rather dull example� Beforegiving more examples� let us insert a remark about terminology�
In order to emphasize that we speak of an ordering which is notnecessarily linear� we sometimes use the longer term partial ordering�A partial ordering thus means exactly the same as ordering �with�out further adjectives� so a partial ordering may also happen to belinear� Similarly� instead of an ordered set� one sometimes speaks ofa partially ordered set� To abbreviate this long term� the arti�cialword poset is frequently used�
Let us describe more interesting examples of partially orderedsets�
���� Example� Let us imagine we intend to buy a refrigerator�say� We simplify the complicated real situation by a mathematicalabstraction� and we suppose that we only look at three numericalparameters of refrigerators� their cost� electricity consumption� andthe volume of the inner space� If we consider two types of refrigera�tors� and if the �rst type is more expensive� consumes more power�and a smaller amount of food �ts into it� then the second type canbe considered a better onea large majority of buyers of refrigera�tors would agree with that� On the other hand� someone may prefera smaller and cheaper refrigerator� another may prefer a larger re�frigerator even if it costs more� and an environmentally concerned
�� Introduction and basic concepts
customer may even buy an expensive refrigerator if it saves power�The relation �to be clearly worse� �denote it by � in this sense
is thus a partial ordering on refrigerators or� mathematically re�formulated� on the set of triples �c� p� v of real numbers �c stands forcost� p for power consumption� and v for volume� de�ned as follows�
�c�� p�� v� � �c�� p�� v� if and only ifc� � c�� p� � p�� and v� � v��
����
���� Example� For natural numbers a� b� the symbol ajb means �adivides b�� In other words� there exists a natural number c such thatb � ac� The relation �j� is a partial ordering on N� We leave theveri�cation of this to the reader�
���� Example� Let X be a set� Recall that the symbol �X denotesthe system of all subsets of the set X� The relation ��� �to be asubset de�nes a partial ordering on �X�
Drawing partially ordered sets� Finite orderings can be drawnusing arrows� as with any other relations� Typically� such drawingswill contains lots of arrows� For instance� for a ���element linearlyordered set we would have to draw �� % �% � � �% � � �� arrows andloops� A number of arrows can be reconstructed from transitivity�however� if we know that x � y and y � z� then also x � z� so wemay leave out the arrow from x to z� Similarly� we need not drawthe loops� since we know they are always there� For �nite orderedsets� all the information is captured by the relation of �immediatepredecessor�� which we are now going to de�ne�
Let �X�� be an ordered set� We say that an element x � X isan immediate predecessor of an element y � X if
� x � y� and
� there is no t � X such that x � t � y�
Let us denote the just�de�ned relation of immediate predecessorby ��
The claim that the ordering� can be reconstructed from the relation� may be formulated precisely as follows�
����� Proposition� Let X�� be a nite ordered set� and let � bethe corresponding immediate predecessor relation� Then for any twoelements x� y � X � x � y holds if and only if there exist elementsx�� x�� � � � � xk � X such that x�x�� � � ��xk � y �possibly with k � �i�e� we may also have x� y��
��� Ordered sets ��
Proof� One implication is easy to see� if we have x�x�� � � ��xk� y�then also x � x� � � � � � xk � y since the immediate predecessorrelation is contained in the ordering relation� and by the transitivityof �� we have x � y�The reverse implication is not di�cult either� and we prove it by
induction� We prove the following statement�
Lemma� Let x� y � X � x � y� be two elements such that there existat most n elements t � X satisfying x � t � y �i�e� �between� x and y��Then there exist x�� x�� � � � � xk � X such that x� x� � � � �� xk � y�
For n � � the assumption of this lemma asserts that there exists no twith x � t � y� and hence x�y� which means that the statement holdswe choose k � �Let the lemma hold for all n up to some n�� and let us have x � y
such that the set Mxy � ft � X � x � t � yg has n � n� � � elements�Let us choose an element u � Mxy� and consider the sets Mxu � ft �X � x � t � ug and Muy de�ned similarly� By the transitivity of � itfollows that Mxu �Mxy and Muy �Mxy� Both Mxu and Muy have atleast one element less than Mxy since u ��Mxu� u ��Muy� and by theinductive hypothesis� we �nd elements x�� � � � � xk and y�� � � � � y� in sucha way that x�x�� � � ��xk�u and u� y�� � � �� y�� y� By combiningthese two �chains� we obtain the desired sequence connecting x and y�
�
By the above proposition� it is enough to draw the relation ofimmediate predecessor by arrows� If we accept the convention thatall arrows in the drawing will be directed upwards �this means thatif x � y then x is drawn higher than y� we need not even draw thedirection of the arrowsit is enough to draw segments connectingthe points� Such a picture of a partially ordered set is called its Hassediagram� The following �gure shows a ��element linearly ordered set�such as �f�� �� � � � � �g���
The next drawing depicts the set f�� �� � � � � ��g ordered by the divis�ibility relation �see Example ������
�� Introduction and basic concepts
�
�
�
� �
����
�
The following �gure is a Hasse diagram of the set f�� �� �gf�� �� �gwith ordering � given by the rule �a�� b� � �a�� b� if and only ifa� � a� and b� � b��
�� �
�� �
�� �
�� �
�� �
�� �
�� �
�� �
�� �
Finally� here is a Hasse diagram of the set of all subsets of f�� �� �gordered by inclusion�
f�g f�g f�g
f�� �g
f�� �� �g
f�� �g f�� �g
Further examples and notions concerning posets are left to the exer�cises� The theory of �nite posets is an important and ourishingbranch of combinatorics� The reader can learn about it in Trot�ter �����
Exercises
�� Describe all relations on a set X which are equivalences and partialorderings at the same time�
�� Let R and S be arbitrary partial orderings on a set X � Decide whichof the following relations are necessarily partial orderings�
a R � Sb R � S
��� Ordered sets ��
c R n Sd R S�
�� Verify that the relation ��� in Example ����� indeed de�nes a partialordering�
�� �Let R be a relation on a set X such that there is no �nite sequenceof elements x�� x�� � � � � xk of X satisfying x�Rx�� x�Rx��� � � � xk��Rxk�xkRx� we say that such an R is acyclic� Prove that there exists anordering � on X such that R ��� You may assume that X is �nite ifthis helps�
�� a Consider the set f�� �� � � � � ng ordered by the divisibility relationj see Example ������ What is the maximum possible number of el�ements of a set X � f�� �� � � � � ng which is ordered linearly by therelation j such a set X is called a chain�
b Solve the same question for the set �f��������ng ordered by the rela�tion � see Example ������
�� Show that Proposition ����� does not hold for in�nite sets�
�� Let X�� be a poset� An element a � X is called
� a largest element of X if for every x � X � x � a holds� and� a maximal element of X if there exists no y � X such that a � y�
A smallest element and a minimal element are de�ned similarly�
a Show that a largest element is always maximal� and �nd an exampleof a poset with a maximal element but no largest element�
b Find a poset having no smallest element and no minimal elementeither� but possessing a largest element�
�� �Let � be any partial ordering on a set X � A linear extension of �is any linear ordering � on X such that x � y implies x � y for allx� y � X � If it didn�t look so strange we could write this conditioncompactly as ���� Prove that any partial ordering on a �nite setX has at least one linear extension�
�� Let X��� Y�� be ordered sets� We say that they are isomorphicmeaning that they �look the same� from the point of view of orderingif there exists a bijection f �X � Y such that for every x� y � X � wehave x � y if and only if fx � fy�
a Draw Hasse diagrams for all nonisomorphic ��element posets�
b Prove that any two n�element linearly ordered sets are isomorphic�
c Find two nonisomorphic linear orderings of the set of all naturalnumbers�
d Can you �nd in�nitely many nonisomorphic linear orderings of N��Uncountably many for readers knowing something about the cardi�nalities of in�nite sets�
�� Introduction and basic concepts
� � �Show that for every �nite poset X�� there exists a �nite set Aand a system M of subsets of A such that the ordered set M��is isomorphic to X��� Isomorphism of posets has been de�ned inExercise ��
��� Let X�� be a poset and let A � X be its subset� An element s � Xis called a supremum of the set A if the following holds�
� a � s for each a � A�
� if a � s� holds for all a � A� where s� is some element of X � thens � s��
The in�mum of a subset A � X is de�ned analogously� but with allinequalities going in the opposite direction�
a Check that any subset A � X has at most one supremum andat most one in�mum� The supremum of A� if it exists� is denoted bysupA� Similarly inf A denotes the in�mum�
b Which element is the supremum of the empty set according to thede�nition just given�
c Find an example of a poset in which every nonempty subset hasan in�mum� but there are nonempty subsets having no supremum�
d �Let X�� be a poset in which every subset including the emptyone has a supremum� Show then that every subset has an in�mum aswell�
��� Consider the poset N� j ordering by divisibility�a Decide whether each nonempty subset of N has a supremum�
b Decide whether each nonempty �nite subset of N has a supremum�
c Decide whether each nonempty subset has an in�mum�
�
Combinatorial counting
In this chapter� we are going to consider problems concerning thenumber of various con�gurations� such as �How many ways are thereto send n distinct postcards to n friends��� �How many mappingsof an n�element set to an m�element sets are there��� and so on� Webegin with simple examples that can usually be solved with commonsense �plus� maybe� some cleverness and require no special knowl�edge� Later on� we will come to somewhat more advanced techniques�
��� Functions and subsetsAs promised� we begin with a simple problem with postcards�
Problem� Professor X� �no real person meant� having completeda successful short�term visit at the School of Mathematical Contem�plation and Machine Cleverness in the city of Y�� strolls around onesunny day and decides to send a postcard to each of his friends Alice�Bob� Arthur� Merlin� and HAL������ A street vendor nearby sells ��kinds of postcards with great sights of Y��s historical center� Howmany possibilities does Professor X� have for sending postcards tohis � friends�
Since the postcard for each friend can be picked in �� ways� andthe � selections are independent �making some of them doesn�t in� uence the remaining ones� the answer to this problem is ���� In amore abstract language� we have thereby counted the number of allmappings of a ��element set �Prof� X��s friends to a ���element set�the postcard types� Here is another closely related problem�
Problem� How many distinct ��letter words are there �using the���letter English alphabet� and including meaningless words such asywizp��
�Who can tell which words are meaningless� It might mean something inTralfamadorian� say�
�� Combinatorial counting
Since each of the � letters can be picked independently in �� ways� itis not hard to see that the answer is again ���� And� indeed� a ��letterword can be understood as a mapping of the set f�� �� � � � � �g to theset fa� b� � � � � zg of letters� for each of the � positions in the word�numbered �� �� � � � � �� we specify the letter in that position� Findingsuch simple transformations of counting problems is one of the basicskills of the art of counting�
In the next proposition� we count mappings of an n�element setto an m�element set� The idea is exactly the same as for countingthe ways of sending the postcards� but we use this opportunity topractice more rigorous mathematical proofs in a simple situation�
����� Proposition� Let N be an n�element set �it may also be
empty� i�e� we admit n � �� �� �� � � �� and let M be an m�element
set� m � �� Then the number of all possible mappings f �N � Mis mn�
Proof� We can proceed by induction on n� What does the propo�sition say for n � �� In this case� we consider all mappings f of theset N � � to some set M � The de�nition of a mapping tells us thatsuch an f should be a set of ordered pairs �x� y with x � N � �and y �M � Since the empty set has no elements� f cannot possiblycontain any such ordered pairs� and hence the only possibility is thatf is the empty set �no ordered pairs� On the other hand� f � � doesindeed satisfy the de�nition of a mapping in this case� the de�nitionsays that for each x � N something should be true� but there are nox � N � Therefore� exactly � mapping f � � � M exists� This agreeswith the formula� because m� � � for any m � �� We have veri�edthe n � � case as a basis for the induction�
Many would object that a mapping of the empty set makes no senseand so it is useless to consider it� and we could really start the inductionwith n � � without any di�culty� But� in mathematical considerations�it often pays to clarify such �borderline� cases� to �nd out what exactlythe general de�nition says about them� This allows us to avoid variousexceptions and special cases later on� or missing cases and mistakes inproofs� It is similar to the usefulness of de�ning an empty sum with noaddends as etc�
Next� suppose that the proposition has been proved for all n � n�and for allm � �� We set n � n�%� and we consider an n�element setN and an m�element set M � Let us �x an arbitrary element a � N �To specify a mapping f �N �M is the same as specifying the value
��� Functions and subsets ��
f�a � M plus giving a mapping f ��N n fag � M � The value f�acan be chosen inm ways� and for the choice of f � we have mn�� waysby the inductive hypothesis� Each choice of f�a can be combinedwith any choice of f �� and so the total number of possibilities forf equals m � mn�� � mn� Here is a picture for the more visuallyoriented reader�
NM
a m possibilitiesto map a
the rest canbe mapped inmn�� ways
�
����� Proposition� Any n�element set X has exactly �n subsets
�n � ���
This is another simple and well�known counting result� Let usgive two proofs�
First proof �by induction�� For X � �� there exists a singlesubset� namely �� and this agrees with the formula �� � ��
Having an �n % ��element set X� let us �x one element a � X�and divide the subsets of X into two classes� those not containing aand those containing it� The �rst class are exactly all the subsets ofthe n�element set X n fag� and their number is �n by the inductivehypothesis� For each subset A of the second class� let us consider theset A� � A n fag� This is a subset of X n fag� Clearly� each subsetA� � X n fag is obtained from exactly one set A of the second class�namely from A� � fag� In other words� there is a bijection betweenall subsets of the �rst class and all subsets of the second class� Hencethe number of subsets of the second class is �n as well� and altogetherwe have �n % �n � �n� subsets of the �n % ��element set X as itshould be� �
Second proof �reduction to a known result�� Consider anarbitrary subset A of a given n�element set X� and de�ne a mappingfA�X � f�� �g� For an element x � X we put
fA�x �
�� if x � A� if x � A�
� Combinatorial counting
�This mapping is often encountered in mathematics� it is called thecharacteristic function of the set A� Schematically�
XA
fA � � �
Distinct sets A have distinct mappings fA� and conversely� any givenmapping f �X � f�� �g determines a subset A � X with f � fA�Hence the number of subsets of X is the same as the number of allmappings X � f�� �g� and this is �n by Proposition ������ �
Now� a bit more di�cult result�
����� Proposition� Let n � �� Each n�element set has exactly �n��
subsets of an odd size and exactly �n�� subsets of an even size�
Proof� We make use of Proposition ������ Let us �x an elementa � X� Any subset A � X n fag can be completed to a subsetA� � X with an odd number of elements� by the following rule� ifjAj is odd� we put A� � A� and for jAj even� we put A� � A � fag�It is easy to check that this de�nes a bijection between the systemof all subsets of X n fag and the system of all odd�size subsets of X�Therefore� the number of subsets of X of odd cardinality is �n���
For subsets of an even size� we can proceed similarly� or we cansimply say that their number must be �n minus the number of odd�size subsets� i�e� �n � �n�� � �n��� �
Later on� we will examine several more proofs�
Injective mappings�
Problem� Professor X�� having spent some time contemplating theapproximately �� million possibilities of sending his postcards� re�turned to the street vendor and wanted to buy his selection� But thevendor had already sold all the postcards and was about to close�After some discussion� he admitted he still had one sample of each ofthe �� postcards� and was willing to sell � of them to Professor X� for(� apiece� In this situation� Professor X� has to make a new decisionabout which postcard is best for whom� How many possibilities doeshe have now�
As Professor X� �and probably the reader too recognized� one hasto count one�to�one mappings from a ��element set to a ���element
��� Functions and subsets ��
set� This is the same as counting ��letter words with all letters dis�tinct�
����� Proposition� For given numbers n�m � �� there exist exactly
m�m� � � � � �m� n% � �n��Yi��
�m� i
one�to�one mappings of a given n�element set to a given m�element
set�
Proof� We again proceed by induction on n �and more concisely thistime� For n � �� the empty mapping is one�to�one� and so exactly� one�to�one mapping exists� and this agrees with the fact that thevalue of an empty product has been de�ned as �� So the formulaholds for n � ��
Next� we note that no one�to�one mapping exists for n � m�and this again agrees with the formula �since one factor equal to �appears in the product�
Let us now consider an n�element set N � n � �� and anm�elementset M � m � n� Fix an element a � N and choose the value f�a �Marbitrarily� in one of m possible ways� It remains to choose a one�to�one mapping of the set Nnfag to the setMnff�ag� By the inductiveassumption� there are �m� ��m� � � � � �m�n%� possibilities forthe latter choice� Altogether we have m�m���m�� � � � �m�n%�one�to�one mappings f �N � M � �Where is a picture� Well� thesedays� you can�t expect to have everything in a book in this pricecategory� �
As we have noted for the postcards and ��letter words� choosing aone�to�one mapping of an n�element set to an m�element set can also beviewed as selecting n objects fromm distinct objects� where the order ofthe selected objects is important i�e� we construct an ordered n�tuple�Such selections are sometimes called variations of n elements from melements without repetition�
Exercises
�� Let X � fx�� x�� � � � � xng be an n�element set� Describe how each sub�set of X can be encoded by an n�letter word consisting of the lettersa and b� Infer that the number of subsets of X is �n� This is verysimilar to the second proof of Proposition ������
�� Combinatorial counting
�� Determine the number of ordered pairs A�B� where A � B �f�� �� � � � � ng�
�� Let N be an n�element set andM an m�element set� De�ne a bijectionbetween the set of all mappings f �N � M and the n�fold Cartesianproduct Mn�
�� Among the numbers �� �� � � � � � ��� are there more of those containingthe digit � in their decimal notation� or of those with no ��
�� a How many n � n matrices are there with entries chosen from thenumbers � �� � � � � q � ��b �Let q be a prime� How many matrices as in a have a determinantthat is not divisible by q� In other words� how many regular matricesover the q�element �eld are there�
�� �Show that a natural number n � has an odd number of divisorsincluding � and itself if and only if
pn is an integer�
��� Permutations and factorials
A bijective mapping of a �nite set X to itself is called a permutationof the set X�
If the elements of X are arranged in some order� we can also imag�ine a permutation as rearranging the elements in a di�erent order�For instance� one possible permutation p of the set X � fa� b� c� dgis given by p�a � b� p�b � d� p�c � c� and p�d � a� This can alsobe written in a two�row form��
a b c db d c a
��
In the �rst row� we have listed the elements of X� and under eachelement x � X in the �rst row� we have written the element p�x intothe second row� Most often one works with permutations of the setf�� �� � � � � ng� If we use the convention that the �rst row always liststhe numbers �� �� � � � � n in the natural order� then it su�ces to writethe second row only� For example� �� � � � denotes the permutationp with values p�� � �� p�� � �� p�� � �� and p�� � ��
In the literature� permutations of a set X are sometimes understoodas arrangements of the elements of X in some order� i�e� as linear order�ings on the set X � This may be a quite useful point of view� but we willmostly regard permutations as mappings� This has some formal advan�tages� For instance� permutations can be composed as mappings�
��� Permutations and factorials ��
Yet another way of writing permutations is to use their so�calledcycles� Cycles are perhaps easiest to de�ne if we depict a permuta�tion using arrows� in the way we depicted relations using arrows inSection ���� In the case of a permutation p�X � X� we draw the ele�ments of the set X as dots� and we draw an arrow from each dot x tothe dot p�x� For example� for the permutation p � �� � � � � � � � ��this is the one�line notation introduced above�� such a picture looksas follows�
� �
�
�
�
� �
�
�
Each point has exactly one outgoing arrow and exactly one ingoingarrow� It is easy to see that the picture of a permutation consistsof several disjoint groups of dots� where the dots in each group areconnected by arrows into a cycle� One can walk around such a cy�cle in one direction following the arrows� The groups of elementsconnected together by these cycles are called the cycles of the con�sidered permutation� �Any reader who is not satis�ed with this pic�torial de�nition can �nd a formal de�nition of a cycle in Exercise ��Using the cycles� the depicted permutation p can also be writtenp � ���� �� �� �� ������ �� �� In each of the inner parentheses� theelements of one cycle are listed in the order along the arrows� start�ing with the smallest element in that cycle�
What can permutations be good for� They are studied� for instance�in the design and analysis of various sorting algorithms� Certain e�cientalgorithms for problems with graphs� or with geometric objects� startby rearranging the input objects into a random order� i�e� by performinga random permutation with them� In the so�called group theory� whichis extremely important in almost all mathematics and also in manyareas of modern physics� groups of permutations with composition asthe group operation are one of the basic objects of study� An ultimatereason for the impossibility of a general algebraic solution of algebraicequations of degree � is in the properties of the group of all permutationson the ��element set� Rubik�s Cube� a toy which used to be extremelypopular at the beginning of the ��� s� provides a pretty example ofa complicated permutation group� Surprisingly involved properties of
�� Combinatorial counting
permutations are applied in a mathematical analysis of card shu ing�This is just a small sample of areas where permutations play a role�
According to Proposition ������ the number of permutations ofan n�element set is n�n� � � � � � � � � �� This number� regarded as afunction of n� is denoted by n� and is called n factorial� Hence wehave
n� � n�n� � � � � � � � � � �n��Yj��
�n� j �nYi��
i�
In particular� for n � � we have �� � � �because �� is de�ned as theempty product�
Exercises
�� How many permutations of f�� �� � � � � ng have a single cycle��� For a permutation p�X � X � let pk denote the permutation arisingby a k�fold composition of p� i�e� p� � p and pk � p pk��� De�ne arelation � on the set X as follows� i � j if and only if there exists ak � such that pki � j� Prove that � is an equivalence relation onX � and that its classes are the cycles of p�
�� Let p be a permutation� and let pk be de�ned as in Exercise �� Bythe order of the permutation p we mean the smallest natural numberk � such that pk � id� where id denotes the identity permutationmapping each element onto itself�
a Determine the order of the permutation � � � � � � � � ��
b Show that each permutation p of a �nite set has a well�de�ned�nite order� and �show how to compute the order using the lengths ofthe cycles of p�
�� CS Write a program that lists all permutations of the set f�� �� � � � � ng�each of them exactly once� Use a reasonable amount of memory evenif n�� the number of permutations� is astronomically large� �Can youmake the total number of operations of the algorithm proportional ton�� if the operations needed for the output printing the permutations�say are not counted�
�� This is an exercise for those who are getting bored by the easy materialcovered in the �rst two sections of this chapter� Let p be a permuta�tion of the set f�� �� � � � � ng� Let us write it in the one�line notation� andlet us mark the increasing segments in the resulting sequence of num�bers� for example� � � � � � � � �� Let fn� k denote the number ofpermutations of an n�element set with exactly k increasing segments�
��� Binomial coe�cients ��
a �Prove that fn� k � fn� n � � � k� and derive that the aver�age number of increasing segments of a permutation is n� ��� theaverage is taken over all permutations of f�� �� � � � � ng�b �Derive the following recurrent formula�fn� k � k � fn� �� k � n� �� kfn� �� k � ��c Using b� determine the number of permutations of f�� �� � � � � ngwith � increasing segments� with � increasing segments� and �with kincreasing segments�
d �For a randomly chosen permutation � of the set f�� �� � � � � ng� cal�culate the probability that the �rst increasing segment has length k�Show that for n large� the average length of the �rst increasing seg�ments approaches the number e� ��Remark� These and similar questions have been studied in the analysisof various algorithms for sorting�
�� Let � be a permutation of the set f�� �� � � � � ng� We say that an orderedpair i� j � f�� �� � � � � ng � f�� �� � � � � ng is an inversion of � if i � jand �i � �j�
a Prove that the set I� of all inversions� regarded as a relation onf�� �� � � � � ng� is transitive�b Prove that the complement of I� is transitive too�
c CS Consider some sorting algorithm which rearranges n input num�bers into a nondecreasing order� and in each step� it is only allowed toexchange two neighboring numbers in the current order� Prove thatthere are input sequences whose sorting requires at least cn� steps ofthis algorithm� where c � is some suitable constant�
d ��CS Can you design an algorithm that calculates the number ofinversions of a given permutation of f�� �� � � � � ng using substantiallyless than n� steps� See e�g� Knuth ���� for several solutions�
�� a �Find out what is the largest power of � dividing the number � �i�e� the number of trailing zeros in the decimal notation for � ��
b �Find a general formula for the highest power k such that n� isdivisible by pk� where p is a given prime number�
�� Show that for every k� n �� k�n divides kn��
��� Binomial coecients
Let n � k be nonnegative integers� The binomial coe�cient�nk
��read
�n choose k� is a function of the variables n� k de�ned by the formula�n
k
��n�n� ��n� � � � � �n� k % �
k�k � � � � � � � � � � �
Qk��i�� �n� i
k�� ����
�� Combinatorial counting
The reader might know another formula� namely�n
k
��
n�
k�n� k�� ���
In our situation� this is equivalent to ���� Among these two possiblede�nitions� the �rst one� ���� has some advantages� The numericalvalue of
�nk
�is more easily computed from it� and one also gets smaller
intermediate results in the calculation� Moreover� ��� makes sense foran arbitrary real number n more about this in Chapter � � and� inparticular� it de�nes the value of
�nk
�also for a natural number n � k�
in such cases��nk
�� �
The basic combinatorial meaning of the binomial coe�cient�nk
�is the number of all k�element subsets of an n�element set� We provethis in a moment� but �rst we introduce some notation�
����� De�nition� Let X be a set and let k be a nonnegative integer�By the symbol �
X
k
�
we denote the set of all k�element subsets of the set X�
For example��fa�b�cg
�
�� ffa� bg� fa� cg� fb� cgg� The symbol
�xk
�has
two meanings now� depending on whether x is a number or a set�The following propositions put them into a close connection�
����� Proposition� For any �nite set X� the number of all k�ele�ment subsets equals
�jXjk
��
In symbols� this statement can be written������X
k
������ ��jXjk
��
Proof� Put n � jXj� We will count all ordered k�tuples of elements ofX �without repetitions of elements in two ways� On the one hand� weknow that the number of the ordered k�tuples is n�n�� � � � �n�k%�by Proposition ����� �see the remark following its proof� On theother hand� from one k�element subset M � �X
k
�� we can create k�
distinct ordered k�tuples� and each ordered k�tuple is obtained fromexactly one k�element subset M in this way� Hence
n�n� � � � � �n� k % � � k�
������X
k
������ ��
��� Binomial coe�cients ��
Another basic problem leading to binomial coe�cients� Howmany ways are there to write a nonnegative integer m as a sum of rnonnegative integer addends� where the order of addends is impor�tant� For example� for n � � and r � �� we have the possibilities� � �%�� � � �%�� � � �%�� and � � �%�� In other words� we wantto �nd out how many ordered r�tuples �i�� i�� � � � � ir of nonnegativeintegers there are satisfying the equation
i� % i� % � � � % ir � m� ����
The answer is the binomial coe�cient�mr��
r���� This can be proved
in various ways� Here we describe a proof almost in the style of amagician�s trick�
Imagine that each of the variables i�� i�� � � � � ir corresponds toone of r boxes� We have m indistinguishable balls� and we want todistribute them into these boxes in some way �we assume that eachbox can hold all the m balls if needed� Each possible distributionencodes one solution of Eq� ����� For example� for m � � and r � ��the solution �%�%�%�%�%� � � corresponds to the distribution
r rr r r r r
So we are interested in the number of distributions of the balls intoboxes� We now let the bottoms and the leftmost and rightmost wallsof the boxes disappear� so that onlym balls and r�� walls separatingthe boxes remain�
r r r r r r r
�we have also moved the balls and walls for a better aesthetic im�pression� This situation still contains full information about thedistribution of the balls into boxes� Hence� choosing a distribution ofthe balls means selecting the position of the internal walls among theballs� In other words� we have m% r � � objects� balls and internalwalls� arranged in a row� and we determine which positions will beoccupied by balls and which ones by walls� This corresponds to aselection of a subset of r� � positions from m% r� � positions� andthis can be done in
�mr��r��
�ways� �
Simple properties of binomial coe�cients� One well�knownformula is
�� Combinatorial counting
�n
k
��
�n
n� k
�� ����
Its correctness �for n � k � � can immediately be seen from thealready�mentioned formula
�nk
�� n�
k��n�k � � Combinatorially� Eq� ����means that the number of k�element subsets of an n�element set isthe same as the number of subsets with n� k elements� This can beveri�ed directly without referring to binomial coe�cientsit su�cesto assign to each k�element subset its complement�
Here is another important formula� attributed to Pascal��n� �
k � �
�%
�n� �
k
��
�n
k
�� ����
One elegant proof is based on a combinatorial interpretation of bothsides of Eq� ����� The right�hand side is the number of k�elementsubsets of some n�element set X� Let us �x one element a � Xand divide all k�element subsets of X into two groups dependingon whether they contain a or not� The subsets not containing a areexactly all k�element subsets of Xnfag� and so their number is
�n��k
��
If A is some k�element subset of X containing a� then we can assignthe �k � ��element set A� � A n fag to A� It is easy to check thatthis assignment is a bijection between all k�element subsets of Xcontaining the element a and all �k� ��element subsets of X n fag�The number of the latter is
�n��k��
�� Altogether� the number of all
k�element subsets of X equals�n��
k
�%�n��k��
�� �
The identity ��� is closely related to the so�called Pascal triangle�
�� �
� � �� � � �
� � � � �� � � � � �
������
Every successive row in this scheme is produced as follows� under eachpair of consecutive numbers in the preceding row� write their sum� andcomplement the new row by �s on both sides� An induction using ���shows that the n � ��st row contains the binomial coe�cients
�n�
���
n�
��� � � �
�nn
��
��� Binomial coe�cients ��
Binomial theorem� Eq� ���� can be used for a proof of anotherwell�known statement involving binomial coe�cients� the binomialtheorem�
����� Theorem �Binomial theorem�� For any nonnegative inte�
ger n� we have
�� % xn �nX
k��
�n
k
�xk ����
�this is an equality of two polynomials in the variable x� so in par�
ticular it holds for any speci�c real number x��
From the binomial theorem� we can infer various relations amongbinomial coe�cients� Perhaps the simplest one arises by substitutingx � �� and it reads�
n
�
�%
�n
�
�%
�n
�
�% � � �%
�n
n
�� �n� ����
Combinatorially� this is nothing else than counting all subsets of ann�element set� On the left�hand side� they are divided into groupsaccording to their size�
Second proof of Proposition ����� �about the number of
oddsize subsets�� By substituting x � �� into the binomial the�orem� we arrive at�
n
�
���n
�
�%
�n
�
���n
�
�% � � � �
nXk��
���k�n
k
�� �� ����
Adding this equation together with Eq� ���� leads to
�
��n
�
�%
�n
�
�%
�n
�
�% � � �
�� �n�
The brackets on the left�hand side contain the total number of even�size subsets of an n�element set� Therefore� the number of even�size subsets equals �n��� The odd�size subsets can be counted as acomplement to �n� �
Further identities with binomial coe�cients� Literally thou�sands of formulas and identities with binomial coe�cients are knownand whole books are devoted to them� Here we present one more for�mula with a nice combinatorial proof� More formulas and methods onhow to derive them will be given in the exercises and in Chapter ���
� Combinatorial counting
����� Proposition�
nXi��
�n
i
��
�
��n
n
��
Proof� The �rst trick is to rewrite the sum using the symmetry ofbinomial coe�cients� ����� as
nXi��
�n
i
��n
n� i
��
Now we show that this sum expresses the number of n�element sub�sets of a �n�element set �and so it equals the right�hand side in theformula being proved� Consider a �n�element set X� and color n ofits elements red and the remaining n elements blue� To choose ann�element subset of X now means choosing an i�element subset ofthe red elements plus an �n� i�element subset of the blue elements�where i � f�� �� � � � � ng�
n red n blue
in� i
X
For a given i� there are�ni
�possibilities to choose the red subset and�
independently�� nn�i
�possibilities for the blue subset� Altogether� an
n�element subset of X can be selected inPn
i��
�ni
�� nn�i
�ways� �
Multinomial coe�cients and the multinomial theorem� Here isone of the favorite problems of American textbooks� how many distinctwords� including nonsense ones� can be produced using all the lettersof the word MISSISSIPPI� In other words� how many distinct ways arethere to rearrange these letters� First� imagine that the letters in thename are distinguished somehow� so that we have � di�erent Ss etc� Inour text� we distinguish them by indices� M�I�S�S�I�S�S�I�P�P�I�� Sowe have �� distinct letters� and these can be permuted in ��� distinctways� Now consider one arbitrary word produced from a �nonindexed�MISSISSIPPI� such as SIPISMSIPIS� From how many �indexed� wordsdo we get this word by deleting the indices� The indices of the � lettersS can be placed in �� ways� the indices of the � letters I can be arrangedindependently in �� ways� for the � letters P we have �� possibilities�and �nally for the single M we have � or �� possibility� Thus� the wordSIPISMSIPIS� and also any other word created from MISSISSIPPI� can
��� Binomial coe�cients ��
be indexed in �������� ways� The number of nonindexed words� which isthe answer to the problem� is �������������The same argument leads to the following general result� if we have
objects of m kinds� ki indistinguishable objects of the ith kind� wherek� � k� � � � � � km � n� then the number of distinct arrangements ofthese objects in a row is given by the expression
n�
k��k�� � � � km��
This expression is usually written�n
k�� k�� � � � � km
�and is called a multinomial coe�cient� In particular� for m � � we get abinomial coe�cient� i�e�
�n
k�n�k�denotes the same thing as
�nk
�� Why the
name �multinomial coe�cient�� It comes from the following theorem�
����� Theorem Multinomial theorem� For arbitrary real numbers x�� x�� � � � � xm and any natural number n �� the following equality holds�
x� � x� � � � �� xmn �
Xk������km�n
k������km��
�n
k�� k�� � � � � km
�xk�� xk�� � � � xkmm �
The right�hand side of this formula usually has fairly many termswe sum over all possible ways of writing n as a sum of m nonnega�tive integers� But the theorem is most often applied to determine thecoe�cient of some particular term� For example� it tells us that thecoe�cient of x�y�z� in x� y � z�� is
���
�����
�� ��� �
The multinomial theorem can be proved by induction on n seeExercise ��� A more natural proof can be given by the methods wediscuss in Chapter � �
Exercises
�� Formulate the problem of counting all k�element subsets of an n�element set as a problem with sending or buying postcards�
�� Prove the addition formula ��� by using the de�nition ��� of bino�mial coe�cients and by manipulating expressions�
�� a Prove the formula�r
r
��
�r � �
r
��
�r � �
r
�� � � ��
�n
r
��
�n� �
r � �
����
by induction on n for r arbitrary but �xed� Note what the formulasays for r � ��
b �Prove the same formula combinatorially�
�� Combinatorial counting
Fig� ��� A graphical derivation of the formula for �� � �� � � � �� n��
�� �For natural numbersm � n calculate i�e� express by a simple formulanot containing a sum
Pnk�m
�km
��nk
��
�� Calculate i�e� express by a simple formula not containing a sum
aPn
k��
�km
��k �
b �Pn
k��
�km
�k�
�� ��Prove thatmXk��
�m
k
��n� k
m
��
mXk��
�n
k
��m
k
��k�
�� �How many functions f � f�� �� � � � � ng � f�� �� � � � � ng are there thatare monotone� that is� for i � j we have fi � fj�
�� How many terms are there in the sum on the right�hand side of theformula for x� � � � �� xm
n in the multinomial theorem�
�� �How many k�element subsets of f�� �� � � � � ng exist containing no twoconsecutive numbers�
� � a Using formula ��� for r � �� calculate the sumsPn
i�� ii�� andPni�� i
��
b Using a and ��� for r � �� calculatePn
i�� i��
c �Derive the result of b using Fig� ��� the �gure is drawn for thecase n � ��
��� Prove the binomial theorem by induction on n�
��� Binomial coe�cients ��
��� For a real number x and a natural number n� let the symbol xn denotexx� �x� � � � � x� n�� the so�called nth factorial power of x�Prove the following analog of the binomial theorem�
x � yn �
nXi��
�n
i
�xiyn�i�
Proceed by induction on n�
��� Prove the so�called Leibniz formula for the di�erentiation of a product�Let u� v be real functions of a single real variable� and let f �k� denotethe kth derivative of a function f � Then
uv�n� �
nXk��
�n
k
�u�k�v�n�k�
supposing that all the derivatives in the formula exist� The case n � �is the formula for di�erentiating a product� uv� � u�v � uv�� whichyou may assume as being known�
��� CS Write a computer program that lists all k�element subsets of theset f�� �� � � � � ng� each of them exactly once� Use a reasonable amountof memory even if
�nk
�� the number of such subsets� is very large� �Can
you make the total number of operations of the algorithm proportionalto
�nk
�� if the operations needed for the output are not counted�
��� Let p be a prime and let n� k be natural numbers�
a Prove that for k � p��pk
�is divisible by p�
b Prove that�np
�is divisible by p if and only if bn�pc is divisible
by p�
��� a �Using the binomial theorem� derive a formula for the number ofsubsets of cardinality divisible by � of an n�element set�
b �Count the subsets of size divisible by � of an n�element set�
��� We have n kinds of objects� and we want to determine the number ofways in which a k�tuple of objects can be selected� We consider vari�ants� we may be interested in selecting ordered or unordered k�tuples�and we may have either just � object of each kind or an unlimitedsupply of indistinguishable objects of each kind� Fill out the formulasin the following table�
Only � object Arbitrarily manyof each kind objects of each kind
Ordered k�tuples
Unordered k�tuples
�� Combinatorial counting
��� We have k balls� and we distribute them into n numbered bins� Fillout the formulas for the number of distributions for various variantsof the problem in the following table�
At most � ball Any number of ballsinto each bin into each bin
Balls are distinguishablehave distinct colorsBalls areindistinguishable
��� �How many ways are there to arrange � elves and � goblins in a rowin such a way that no goblins stand next to each other�
� � A table is set with �� large plates� We have � lobsters indistinguishableones and � stu�ed snails also indistinguishable� We are interestedin the number of ways to serve the snails and lobsters on the plates�The order of serving is important� Imagine we were writing a scriptfor a movie� �Put a snail on plate no� �� then serve a lobster on plateno� ��� � � �� Only one item is served at a time� How many ways arethere if
a if there are no restrictions� everything can come on the same plate�say� and
b if at least � item should come on each plate�
��� Draw a triangle ABC� Draw n points lying on the side AB but dif�ferent from A and B and connect all of them by segments to thevertex C� Similarly� draw n points on the side AC and connect themto B�
a How many intersections of the drawn segments are there� Into howmany regions is the triangle ABC partitioned by the drawn segments�
b �Draw n points also on the side BC and connect them toA� Assumethat no � of the drawn segments intersect at a single point� How manyintersections are there now�
c �How many regions are there in the situation of b�
��� Consider a convex n�gon such that no � diagonals intersect at a singlepoint� Draw all the diagonals i�e� connect every pair of vertices by asegment�
a �How many intersections do the diagonals determine�
b �Into how many parts is the polygon divided by the diagonals�
��� Cayley�s problem �Consider a regular convex n�gon P with verticesA�� A�� � � � � An� Howmany ways are there to select k of these n vertices�in such a way that no two of the selected vertices are consecutive
��� Binomial coe�cients ��
in other words� if we draw the polygon determined by the selectedvertices� it has no side in common with P � Hint� First� calculate thenumber of such selections including A��
��� �Consider a regular n�gon� We divide it by nonintersecting diagonalsinto triangles i�e� we triangulate it� in such a way that each of theresulting triangles has at least one side in common with the originaln�gon�
a How many diagonals must we draw� How many triangles do weget�
b �How many such triangulations are there�
��� a What is the coe�cient of x�y�z in the polynomial �x� y���z�What about the coe�cient of x�y�z�
b Find the coe�cient of x�y�z in �x� y� � �z �c What is the coe�cient of u�v�z� in �uv � �z � u� v �
��� a Prove the equality�n
k�� k�� � � � � km
��
�n� �
k� � �� k�� k�� � � � � km
�
�
�n� �
k�� k� � �� k�� � � � � km
�
� � � ���
n� �k�� k�� � � � � km��� km � �
�
n �� k� � � � �� km � n� ki ��b Prove the multinomial theorem by induction on n�
��� Count the number of linear extensions for the following partial order�ings a linear extension has been de�ned in Exercise ������
a X is a disjoint union of sets X�� X�� � � � � Xk of sizes r�� r�� � � � � rk�respectively� Each Xi is linearly ordered by �� and no two elementsfrom the di�erent Xi are comparable�
b �The Hasse diagram of X�� is a tree as in the following picture�The root has k sons� the ith son has ri leaves�
� � �
�� Combinatorial counting
��� Estimates� an introductionIf we are interested in some quantity and we ask the question �Howmuch��� the most satisfactory answer seems to be one determining thequantity exactly� A millionairess may �nd some fascination in knowingthat her account balance is � ������������ doublezons� at the moment�In mathematics� an answer to a counting problem is usually consideredmost satisfactory if it is given by an exact formula� But quite often wedo not really need an exact result� for many applications it is enough toknow a quantity approximately� For instance� many people may �nd itsu�cient� although perhaps not comforting� to learn that their accountbalance is between � and �� doublezons� Often even a one�sidedinequality su�ces� if we estimate that a program for �nding an optimalproject schedule by trying all possibilities would run for at least � ��
days� we probably need not put further e�ort into determining whetherit would actually run for more than � �� days or less than that�
Exact results may be di�cult to �nd� Sometimes computing an exactresult may be possible but laborious� and sometimes it is beyondour capabilities no matter how hard we try� Hence� heading for anestimate instead of the exact result may save us lots of work andconsiderably enlarge the range of problems we are able to cope with�
Another issue is that an exact answer may be di�cult to graspand relate to other quantities� Of course� if the answer is a singlenumber� it is easy to compare it to other numbers� but the situationis more delicate if we have a formula depending on one or severalvariables� Such a formula de�nes a function� say a function of n� andwe would like to understand �how big� this function is� The usualapproach is to compare the considered function to some simple andwell�known functions� Let us give a nontrivial example �rst�
����� Example �Estimating the harmonic numbers�� The fol�lowing sum appears quite often in mathematics and in computerscience�
Hn � � %�
�%
�
�% � � � % �
n�
nXi��
�
i�
This Hn is called the nth harmonic number� It turns out that thereis no way to simplify this sum �it has no �closed form�� We wantto get some idea about the behavior of Hn for n growing to �� Inparticular� we want to decide whether Hn �� for n���
�Doublezon is a currency unit taken from the book L��Ecume des jours �Englishtranslation� Froth on the Daydream� by Boris Vian�
��� Estimates� an introduction ��
�
� � �
G�
G�
G�
G�
i
Fig� ��� Partitioning the sequence �� ��� �
�� � � � � into groups�
A simple estimate� The idea is to divide the terms of the sequence�� �
�� �
�� � � � � into groups� each group consisting of numbers that are
roughly of the same magnitude� That is� we let the kth group Gk
consist of the numbers �i with
�
�k�
�
i� �
�k��
�see Fig� ����Hence Gk contains the �k�� numbers
�
�k���
�
�k�� % ��
�
�k�� % �� � � � �
�
�k � ��
Therefore� the sum of the terms in each Gk satis�es
Xx�Gk
x � jGkjmaxGk � �k���
�k��� ��
and similarly
Xx�Gk
x � jGkjminGk � �k���
�k�
�
��
A given term �i belongs to the group Gk with �k�� � i � �k� i�e�
with k � blog� ic % �� Therefore� Hn is no bigger than the sum ofnumbers in the �rst blog� nc% � groups� and we get
�� Combinatorial counting
Hn �nXi��
�
i�
blog� nc�Xk��
� � log� n% ��
Similarly we can derive a lower bound
Hn �
blog� ncXk��
�
�� �
�blog� nc�
We may conclude that Hn does grow to in�nity but quite slowly�about as slowly as the logarithm function� Even for very large valuesof n� we can estimate the value of Hn by computing the logarithm�If n is large� the ratio of the upper and lower bounds is close to ��
For somewhat more sophisticated and more precise estimates ofHn� see Exercise �������
In this example� we seem to have been lucky� We could approximatethe considered function Hn quite closely by suitable multiples of thelogarithm function� But experience shows� and certain theoretical re�sults con�rm� that this is not an exceptional luck� and that functionsof a single variable n occurring in natural problems can usually beestimated fairly accurately by everyday functions like n� n�� n������ �n�����n� �n
���� lnn� ���nlnn
�� etc� But �nding such estimates may oftenbe quite tricky� In the subsequent sections� we will demonstrate severaltechniques which may be helpful in such an e�ort�
Asymptotic comparison of functions� In the above example�we have shown that the function Hn is �smaller� than the functionlog� n%�� meaning that the inequality Hn � log� n% � holds for alln � N� But if we consider the functions f�n � �n and g�n � n��then neither is smaller than the other� strictly speaking� since� forexample� f�� � � � g�� � � but f�� � �� � g�� � ��� soneither of the inequalities f�n � g�n and f�n � g�n is correctfor all n� Yet we feel that g �grows much faster� than f � after someinitial hesitation for small values of n� g�n exceeds f�n and remainsabove it for all the larger n�
In mathematics and in theoretical computer science� functionsde�ned on the natural numbers are usually compared according totheir behavior as n tends to in�nity� while their behavior for smallvalues n are ignored� This approach is usually called the asymptoticanalysis of the considered functions� We also speak of the asymptoticbehavior or asymptotics of some function� meaning its comparison tosome simple functions for n���
��� Estimates� an introduction ��
If f and g are real functions of a single variable n� we may introducethe symbol f � g� meaning that there exists some number n� such thatthe inequality fn � gn holds for all n n�� that is� �g ultimatelyoutgrows f�� So� for the example in the preceding paragraph� we canwrite �n � n��It is useful to think a bit about the relation � just introduced� It
can be viewed as a �soft� inequality between the considered functions�If f � g holds� we are sure that g outgrows f for large enough n butwe generally do not know how large n must be� The notation � thussuppresses some information� This often makes it much easier to derivethe � inequality between two functions than to prove the �hard� in�equality � which should hold for all n� But it may also make the �inequality treacherous for the �end�user�� Suppose that someone sellsus a black box that� for each input number n� computes and displayssome value fn� We also get a guarantee that fn � n� We can neverreally prove that the guarantee is invalid� No matter how many of then we �nd with fn � n� the seller can always claim that the numbern� implicit in the guarantee is still much bigger than our examples�The notation f � g is not common in the literature although we
believe it has some didactical value for understanding the other nota�tions to come� Instead� several other notations are used that suppressstill somewhat more information� and thus may make the estimates yetmore convenient to derive�
The �bigOh� notation� The following notation is used quiteoften� for instance� it appears frequently in the analysis of algorithms�
����� De�nition� Let f� g be real functions of a single variable de�
�ned on the natural numbers �most often we assume that the values
attained by both f and g are nonnegative�� The notation
f�n � O�g�n
means that there exists a constant C such that for all n � N� the
inequality jf�nj � C � g�n holds� If one has to read f�n � O�g�naloud one usually says f is big�Oh of g�
Here the information suppressed by the notation f�n � O�g�nis the value of the constant C� It may be ���� ��� or ����we onlylearn that some constant C exists� The notation f�n � O�g�ncan intuitively be understood as saying that the function f doesn�tgrow much faster than g� i�e� that f�n�g�n doesn�t grow to in�n�ity� Instead of f�n and g�n� speci�c formulas may appear in thisnotation� For example� we may write ��n� % �n � O�n��
� Combinatorial counting
We should warn that f�n � O�g�n says that f�n is not toobig� but it does not say anything about f�n not being very small�For example� n%� � O�n� is a true statement� although perhaps notas helpful as n% � � O�n� Let us also emphasize that although thenotation contains the equality sign ���� it is asymmetric �essentially�it is an inequality� one shouldn�t write O�f�n � g�n�
The O� notation often allows us to simplify complicated expres�sions wonderfully� For example� we have
��n� % �n% ��n� � �n% �� � O�n�� �����
Why� We note the following two simple rules concerning the O�notation� if we have f��n � O�g��n and f��n � O�g��n thenf��n % f��n � O�g��n % g��n� and similarly for multiplication�f��nf��n � O�g��ng��n �Exercise �� Since obviously n � O�n�and � � O�n�� by a repeated application of the addition and multi�plication rules we get �n� % �n% � � O�n� % n� % n� � O�n�� andsimilarly n���n%�� � O�n�� A �nal application of the multiplica�tion rule gives Eq� ������ A nice thing in this derivation is that wedidn�t need to multiply out the parentheses �rst�
After some practice� one can write estimates)simpli�cations like����� right away without too much thinking� by quickly spotting the�main term� in an expression �the one that grows fastest and lettingall others disappear in the O� notation� Such insight is usually basedon a �maybe subconscious use of the following simple rules�
����� Fact �Useful asymptotic inequalities�� In the following�
let C� a� � � � be some �xed real numbers independent of n� Wehave
�i� n� � O�n� whenever � �a bigger power swallows a smaller
one��
�ii� nC � O�an for any a � � �an exponential swallows a power��
�iii� �lnnC � O�n� for any � � �a power swallows a logarithm��
�In fact� in all the inequalities above� we can write the � symbol
instead of the O� notation��
Part �i is trivial� proving part �ii is a simple exercise in calculus�and part �iii can be easily derived from �ii by taking logarithms�
Using the symbol O�� we can also write a more exact comparisonof functions� For example� the notation f�n � g�n%O�
pn means
��� Estimates� an introduction ��
that the function f is the same as g up to an �error� of the orderpn� i�e� that f�n � g�n � O�
pn� A simple concrete example is�n
�
�� n�n� ��� � �
�n� %O�n�
The next example shows how to estimate a relatively complicatedsum�
����� Example� Let us put fn � �� � �� � �� � � � � � n�� We wantto �nd good asymptotic estimates for fn�
In this case� it is possible to �nd an exact formula for fn seeExercise ����� � but it is quite laborious�� But we can get reasonableasymptotic estimates for fn in a less painful way� First� we may notethat fn � n � n� � n�� On the other hand� at least n
� addends inthe sum de�ning fn are bigger than n���� and so fn n��� �n����� As a �rst approximation� we thus see that fn behaves like thefunction n�� up to small multiplicative factors�To get a more precise estimate� we can employ the summation for�
mula ��� Exercise ����� with r � ����
�
��
��
�
��
��
�
�� � � ��
�n
�
��
�n� �
�
��
Set gk ��k�
�� We �nd that gk � k�k����k���
� � k�
� Ok�� Hencewe have
fn �
nXk��
k� �
nXk��
�gk �
nXk��
�k� � �gk�
� �
�n� �
�
��O
� nXk��
k���n�
��On��
In this derivation� we have used the following fact� if f� g are somefunctions such that fn � Ogn� then
Pnk�� fk � O
Pnk�� gk�
It is a simple but instructive exercise to prove it�
A few more remarks� A similar �big�Oh� notation is also usedfor functions of several variables� For instance� fm�n � Ogm�nmeans that for some constant C and for all values of m and n� we havejfn�mj � C � gm�n�A seemingly di�erent de�nition of the notation fn � Ogn says
that there exist numbers C� and n� � N such that for all n n�� wehave jfnj � C�gn� In this de�nition� it doesn�t matter if the functionf or g is unde�ned for some small values of n� But if both f and g arede�ned for all natural numbers then this de�nition is equivalent to theformer one we leave this as an exercise�
�At least by hand� many computer algebra systems can do it automatically�
�� Combinatorial counting
In the literature� one frequently encounters several other symbols forexpressing �inequality� between the order of magnitude of functions�They can be quite useful since once one gets used to them� they providea convenient replacement for complicated phrases such as �there existsa constant c � such that for all n � N we have � � � � etc�� We willnot discuss them in detail� but we will at least list the de�nitions of themost common symbols in the table below�
Notation De�nition Meaning
fn � ogn limn��f�n�g�n� �
f grows much more slowlythan g
fn � !gn gn � Ofn f grows at least as fast as g
fn � "gnfn � Ogn andfn � !gn
f and g have about thesame order of magnitude
fn � gn limn��f�n�g�n� � �
fn and gn are almostthe same
So� �nally� it is natural to askwhat is a bound f�n � O�g�ngood for� Since it doesn�t say anything about the hidden constant�we cannot deduce an estimate of f�n for any speci�c n from it�There are several answers to this question� In some mathematicalconsiderations� we do not really care about any particular n� and itis enough to know that some function doesn�t grow much faster thananother one� This can be used� for example� to prove the existence ofsome object without actually constructing it �see Chapter � for sucha proof method� A more practically oriented answer is that in mostsituations� the constant hidden in the O� notation can actually be�gured out if needed� One just has to go through a computation donewith the O� notation very carefully once more and track the con�stants used in all the estimates� This is usually tedious but possible�As a general rule of thumb �with many many exceptions� one cansay that if a simple proof leads to an O� estimate then the hiddenconstant is usually not too large� and so if we �nd that f�n � O�nand g�n � *�n� then typically f�n will be smaller than g�n evenfor moderate n� We add more remarks concerning the O� notationin connection with algorithms in Section ����
�� Estimates� the factorial function ��
Exercises
�� Check that the relation � introduced in the text is a partial orderingon the set of all functions f �N � R� Show that it is not a linearordering�
�� Find positive and nondecreasing functions fn� gn de�ned for allnatural numbers such that neither fn � Ogn nor gn � Ofnholds�
�� Explain what the following notations mean� and decide which of themare true�
a n� � On� lnn
b n� � on� lnn
c n� � �n lnn � n��� � o�
� � n�
d n� � �n lnn � n� �On
ePn
i�� i� � "n�
fPn
i��
pi � "n����
�� What is the meaning of the following notations� fn � O�� gn �!�� hn � nO���� How can they be expressed brie�y in words�
�� �Order the following functions according to their growth rate� andexpress this ordering using the asymptotic notation introduced in this
section� n lnn� ln lnnlnn� lnnln lnn� n � eplnn� lnnlnn� n � �ln lnn�
n�����ln lnn�� n���� lnn� n��
�� Check that if we have f�n � Og�n and f�n � Og�n thenf�n � f�n � Og�n � g�n and f�nf�n � Og�ng�n�
��� Estimates� the factorial function
In this section� we are going to consider estimates of the functionn� �n factorial� At the �rst sight� it might seem that the de�nitionof the factorial itself� i�e� the formula n� � n�n� � � � � � � � � �� tellsus everything we may ever need to know� For small values of n� n�can be very quickly evaluated by a computer� and for larger n� onemight think that the values of the factorial are too large to have anysigni�cance in the �real world�� For example� ��� � ������ as manyowners of pocket calculators with the n� button may know� But invarious mathematical considerations� we often need to compare theorder of magnitude of the function n� to other functions� even forvery large values of n� For this purpose� the de�nition itself is notvery suitable� and also an evaluation of n� by a computer sometimes
�� Combinatorial counting
won�t be of much help� What we need are good estimates that boundn� by some �simpler� functions�
When approaching a problem� it is usually a good strategy to startlooking for very simple solutions� and only try something complicatedif simple things fail� For estimating n�� a very simple thing to try isthe inequality
n� �nYi��
i �nYi��
n � nn�
As for a very simple lower bound� we can write
n� �nYi��
i �nYi��
� � �n���
Hence� n� is somewhere between the functions �n�� and nn� In manyproblems� this may be all we need to know about n�� But in otherproblems� such as Example ����� below� we may start asking moresophisticated questions� Is n� �closer� to nn or to �n��� Does thefunction nn
n� grow to in�nity� and if so� how rapidly�To some extent� this can be answered by still quite simple consid�
erations �similar to the �rst part of the solution to Example ������ Ifn is even� then n
� of the numbers in the set f�� �� � � � � ng are at mostn� � and
n� of them are larger than n
� � Hence� for n even� we have� onthe one hand�
n� �nY
i�n���
i �nY
i�n���
n
��
�n
�
�n���
�rn
�
�n
� �����
and on the other hand�
n� �� n��Yi��
n
�
�� nYi�n���
n
��
nn
�n��� �����
For n odd� one has to be slightly more careful� but it turns out that
both the formulas n� ��p
n���n
and n� � nn��n�� can be derived
for all odd n � � as well �Exercise �� So� from Eq� ����� we seethat n� grows considerably faster than �n� in fact� sooner or later itoutgrows any function Cn with a �xed number C� Eq� ����� tells usthat nn grows still faster than n��
Here is a simple example where the question of comparing nn andn� arises naturally�
�� Estimates� the factorial function ��
����� Example� Each of n people draws one card at random from adeck of n cards� remembers the card� and returns it back to the deck�What is the probability that no two of the people draw the same card�Is there some �reasonable chance�� or is it a very rare event� Mathe�matically speaking� what is the probability that a mapping of the setf�� �� � � � � ng to itself chosen at random is a permutation�The number of all mappings is nn� the number of permutations is n��
and so the required probability is n��nn� From the upper bound �����we calculate
n�
nn� nn��n��
nn� ��n���
Therefore� the probability is no more than ��n��� and for n not toosmall� the considered event is extremely unlikely� From more preciseestimates for n� derived later on� we will see that the probability inquestion behaves roughly as the function e�n�
A simple estimate according to Gauss� We show an elegant way ofderiving estimates similar to ���� and ���� but a bit stronger� Thisproof is of some historical interest� since it was invented by the greatmathematician Gauss or� written in the German way� Gau#� and wealso learn an important and generally useful inequality�
����� Theorem� For every n ��
nn�� � n� ��n� �
�
�n
�
We begin the proof with an inequality between the arithmetic andgeometric mean of two numbers� For positive real numbers a� b� we de�nethe arithmetic mean of a and b as a�b
� � and the geometric mean� of a
and b aspab�
����� Lemma Arithmetic�geometric mean inequality� For anypair of positive real numbers a� b� the geometric mean is no bigger thanthe arithmetic mean�
Proof� The square of any real number is always positive� and sopa�pb� � By expanding the left�hand side we have a��pab�b
� and by adding �pab to both sides of this inequality and dividing by
� we getpab � a�b
� � This is the desired inequality� �
Proof of Theorem ������ The idea is to pair up each number i �f�� �� � � � � ng with its �cousin� n���i and estimate each of the products�If g denotes the geometric mean of a and b then the ratio a � g is the same
as g � b� From the point of view of the ancient Greeks� g is thus the appropriatesegment in the middle between a segment of length a and a segment of lengthb� and that�s probably why this mean is called geometric�
�� Combinatorial counting
in��� i from above and from below� If i runs through the values ���� � � � � n then n� �� i runs through n� n� �� � � � � �� The product
nYi��
in� �� i
thus contains each factor j � f�� �� � � � � ng exactly twice� and so it equalsn��� Therefore we have
n� �
nYi��
pin� �� i� ����
If we choose a � i and b � n� �� i in the arithmetic$geometric meaninequality� we getp
in� �� i � i� n� �� i
��
n� �
��
and by ����
n� �
nYi��
pin� �� i �
nYi��
n� �
��
�n� �
�
�n
�
which proves the upper bound in Theorem ������In order to prove the lower bound for n�� it su�ces to show that
in� �� i n for all i � �� �� � � � � n� For i � � and i � n we directlycalculate that in���i � n� For � � i � n��� we have a product of twonumbers� the larger one being at least n
� and the smaller one at least ��
and hence in� �� i n holds for all i� Therefore� n� pnn � nn��
as was to be proved� �
Of course� not everyone can invent such tricks as easily as Gaussdid� but at least the arithmetic$geometric mean inequality is worthremembering�
Having learned some estimates of n�� we may keep asking more
and more penetrating questions� such as whether�n��
�n�n� grows
to in�nity� and if so how fast� etc� We will now skip some stages ofthis natural evolution and prove bounds that estimate n� up to amultiplicative factor of only n �note that in the preceding estimates�our uncertainty was still at least an exponential function of n� Inthese more sophisticated estimates� we encounter the so�called Euler
number e � ����������� � � �� the basis of the natural logarithms�The reader may learn much more about this remarkable constant incalculus� Here we need the following�
�� Estimates� the factorial function ��
���� �� � �� �� � ���
�
�
�
�
Fig� ��� The functions y � ��x and y � ex in the vicinity of the origin�
����� Fact� For every real number x�
� % x � ex
holds �see Fig� �����
This fact is something which should be marked in large bold�faced uorescent letters in the notebook of every apprentice in asymptoticestimates� Here we use it to prove
����� Theorem� For every n � �� we have
e
�n
e
�n� n� � en
�n
e
�n�
First proof �by induction�� We only prove the upper boundn� � en�n�en� leaving the lower bound as Exercise �� For n � ��the right�hand side becomes �� and so the inequality holds� So weassume that the inequality has already been proved for n � �� andwe verify it for n� We have
n� � n � �n� �� � n � e�n� �
�n� �
e
�n��by the inductive assumption� We further transform the right�handside to �
en
�n
e
�n���n� �
n
�ne�
In the brackets� we have the upper bound for n� we want to prove� Soit su�ces to show that the remaining part of the expression cannot
�� Combinatorial counting
y � lnx
� � �� � �
y � lnbxc
Fig� ��� Estimating the area below the step function by integration�
exceed �� By an algebraic manipulation and by using Fact ����� withx � � �
n � we obtain
e
�n� �
n
�n� e
��� �
n
�n� e
�e���n
�n� e � e�� � ��
�
Second proof using an integral� We again do the upper boundonly� We begin with a formula for the factorial� n� � � � � � � � � � n� andwe take natural logarithms on both sides� In this way� we get
lnn� � ln � � ln � � � � �� lnnthe function ln is the logarithm with base e� The expression on theright�hand side can be thought of as the area enclosed between thex�axis and the step function x �� ln bxc on the interval ��� n � ��� seeFig� ����Since ln bxc � lnx on this interval� the area in question is no bigger
than the area below the graph of the function x �� lnx on the interval��� n� ��� We express this latter area as an integral�
lnn� �Z n��
�
lnx dx � n� � lnn� �� n�
as one can calculate as a simple exercise in integration� This estimatecan be further manipulated into
n� � e�n��� ln�n����n �n� �n��
en�
This is not yet the expression we want� But we can use this inequalityfor n� � instead of n� and this gives the formula in the theorem�
�� Estimates� the factorial function ��
n� � n � n� �� � n � nn
en��� en
�ne
�n�
�
For the reader�s interest� let us mention a considerably more preciseestimate for n�� known by the name Stirling�s formula� If we de�ne thefunction
fn �p��n
�ne
�n�
where � � ������������ � � � is the area of the unit disk� we have fn �n�� Recall that this means
limn��
fn
n�� ��
So if we estimate n� by fn then the relative error of this estimatetends to for n tending to in�nity� For example� for n � �� the erroris about �%� Let us note that Stirling�s formula is approximately �inthe middle� of the estimates from Theorem ����� see also Exercise � �Proving Stirling�s formula requires somewhat more advanced tools fromcalculus and it doesn�t quite �t into this book� so we omit it see Knuth���� for a proof�
Exercises
�� a Check that the formula n� ��p
n���nis valid for all odd n ��
by a consideration similar to Eq� �����
b Check that also n� � nn��n�� holds for all odd n ���� Using Fact ������ prove that
a � � �n
n � e for all n �� andb � � � �
n n�� e for all n ��
c Using a and b� conclude that limn��� � �n
n � e�
d Prove �� �n
n � �e � �� �
n n���
�� Calculus required �Prove Fact ������
�� Show that npn tends to � for n � �� and �use Fact ����� to prove
that npn� � lnn
n for all n ���� Decide which of the following statements are true�
a n� � n� ���nb n� � nen�en
c n� � On�en
d lnn� � !n lnn
e lnn� � n lnn�
� Combinatorial counting
�� a For which pairs a� b� a� b � � does the equalitypab � a� b��
hold�
b The harmonic mean of positive real numbers a� b is de�ned by theexpression �ab�a� b� Based on examples� suggest a hypothesis forthe relation inequality of the harmonic mean to the arithmetic andgeometric means� and �prove it�
�� Let x�� x�� � � � � xn be positive reals� Their arithmetic mean equals x��x�� � � ��xn�n� and their geometric mean is de�ned as n
px�x� � � � xn�
Let AGn denote the statement �for any n�tuple of positive realsx�� x�� � � � � xn� the geometric mean is less than or equal to the arith�metic mean�� Prove the validity of AGn for every n by the followingstrange induction�
a Prove that AGn implies AG�n� for each n�
b �Prove that AGn implies AGn� �� for each n � ��c Explain why proving a and b is enough to prove the validity ofAGn for all n�
�� Computation of the number � �De�ne sequences fa�� a�� a�� � � �g andfb�� b�� b�� � � �g as follows� a� � �� b� � �� an�� �
panbn� bn�� �
�an��bn�an�� � bn� Prove that both sequences converge to �� Hint�Find a relation of the sequences to regular polygons with �n sidesinscribed in and circumscribed to the unit circle�
Remark� This method of Archimedes of calculation of � is not verye�cient� Here is an example of a much faster algorithm� x� � �
����������� y� � �
���� �� � � �p�� �n � �n��xn � ��yn � �� yn�� �
ynpxn � ��
pxn�yn � �� xn�� �
pxn � ��
pxn��� Then the �n
converge to � extremely fast� This and other such algorithms� as wellas the remarkable underlying theory� can be found in Borwein andBorwein �����
�� Prove the lower bound n� en�en in Theorem �����
a by induction use Fact ����� cleverly�
b via integration�
� � Calculus required �Prove the following upper bound for the fac�torial function which is already quite close to Stirling�s formula�n� � e
pn n�en� Use the second proof of Theorem ����� as a starting
point� but from the area below the curve y � lnx� subtract the areasof suitable triangles�
��� Prove Bernoulli�s inequality� for each natural number n and for everyreal x ��� we have � � xn � � nx�
��� Estimates� binomial coe�cients ��
��� Prove that for n � �� �� � � �� we have
�pn� �� � � � � �p
���p�� � � �� �p
n� �pn� ��
��� Let Hn be as in Example ������ Hn �Pn
i���i �
a �Prove the inequalities lnn � Hn � lnn�� by induction on n useFact ������
b Solve a using integrals�
��� Estimates� binomial coecients
Similar to the way we have been investigating the behavior of thefunction n�� we will now consider the function�
n
k
��n�n� � � � � �n� k % �
k�k � � � � � � � � � � �k��Yi��
n� i
k � i� �����
From the de�nition of�nk
�� we immediately get�
n
k
�� nk�
and for many applications� this simple estimate is su�cient� Fork � n
� � one should �rst use the equality�nk
��� nn�k
��
In order to derive some lower bound for�nk
�� we look at the def�
inition of the binomial coe�cient written as a product of fractions�as in ������ For n � k � i � � we have n�i
k�i � nk � and hence
�n
k
���n
k
�k�
Quite good upper and lower bounds for�nk
�can be obtained from
Stirling�s formula� using the equality�nk
�� n
k�n�k� � These bounds aresomewhat cumbersome for calculation� however� and also we haven�tproved Stirling�s formula� We do prove good but less accurate estimatesby di�erent methods the main goal is to demonstrate these methods�of course�
����� Theorem� For every n � and for every k� � � k � n� we have�n
k
���enk
�k�
�� Combinatorial counting
Proof� We in fact prove a stronger inequality��n
��
�n
�
��
�n
�
�� � � ��
�n
k
���enk
�k�
We start from the binomial theorem� which claims that�n
��
�n
�
�x�
�n
�
�x� � � � ��
�n
n
�xn � � � xn
for an arbitrary real number x� Let us now assume � x � �� Then byomitting some of the addends on the left�hand side� we get�
n
��
�n
�
�x� � � ��
�n
k
�xk � � � xn�
and dividing this by xk leads to
�
xk
�n
��
�
xk��
�n
�
�� � � ��
�n
k
�� � � xn
xk�
Each of the binomial coe�cients on the left�hand side is multiplied bya coe�cient that is at least � since we assume x � �� and so if wereplace these coe�cients by �s the left�hand side cannot increase� Weobtain �
n
��
�n
�
�� � � ��
�n
k
�� � � xn
xk�
The number x � � � can still be chosen at will� and we do it in sucha way that the right�hand side becomes as small as possible� A suitablevalue� which can be discovered using some elementary calculus� is x � k
n �By substituting this value into the right�hand side� we �nd�
n
��
�n
�
�� � � ��
�n
k
���� �
k
n
�n �nk
�k�
Finally� by using Fact ����� we arrive at�� �
k
n
�n
��ek�n
�n� ek�
and the inequality in Theorem ����� follows� �
The trick used in this proof is a small glimpse into the realm ofperhaps the most powerful known techniques for asymptotic estimates�using the so�called generating functions� We will learn something aboutgenerating functions in Chapter � � but to see the full strength of thisapproach for asymptotic bounds� one needs to be familiar with thetheory of functions of a complex variable�
��� Estimates� binomial coe�cients ��
The binomial coe�cient� nbn��c
�� From the de�nition of the bi�
nomial coe�cients� we can easily get the following formula�
�n
k
��n� k % �
k
�n
k � �
��
Therefore� for k � n�� we have�nk
��
� nk��
�� and conversely� for
k � n�� we obtain�nk
��
� nk�
�� Hence for a given n� the largest
among the binomial coe�cients�nk
�are the middle ones� for n even�� n
n��
�is bigger than all the others� and for n odd� the two largest
binomial coe�cients are� nbn��c
�and
� ndn��e
��
The behavior of the binomial coe�cient�nk
�as a function of k� with
n �xed as some large number and for k close to n��� is illustrated inFig� ���a� The graph of the function
�nk
�isn�t really a continuous curve
since�nk
�is only de�ned for an integer k� but if n is very large� there
are so many points that they visually blend into a curve� The �height�of this bell�shaped curve is exactly
�n
bn��c�� and the �width� of the bell
shape approximately in the middle of its height is about ���pn� The
scales on the vertical and horizontal axes are thus considerably di�erent�the horizontal axis shows a range of k of length �
pn� while the vertical
range is�
nbn��c
�which is nearly �n as we will soon see�
If you plot the function x �� e�x���� you get a curve which looks ex�
actly the same as the one we have plotted for binomial coe�cients� up toa possibly di�erent scaling of the axes� This is because the e�x
��� curve�called the Gauss curve� is a limit of the curves for binomial coe�cientsfor n�� in a suitably de�ned precise sense� The Gauss curve is veryimportant in probability theory� statistics� and other areas� For example�it describes a typical distribution of errors in physical measurements�the percentage of days with a given maximal temperature within a longtime period� and so on� In statistics� the distribution given by the Gausscurve is called the normal distribution� The Gauss curve is one of the�ubiquitous� mathematical objects arising in many often unexpectedcontexts another such omnipresent object is the Euler number e� andwe will meet some others later in this book� You can learn more aboutthe Gauss curve and related things in a probability theory textbookGrimmett and Stirzaker ���� can be highly recommended�
How large is the largest binomial coe�cient� nbn��c
�� A simple but
often accurate enough estimate is
�n
n% ���
n
bn��c
�� �n�
�� Combinatorial counting
n�
n� �
pn n
� �pn
a b
k
Fig� ��� A graph of�nk
�as a function of k in the vicinity of n
� a� or
perhaps a hat� or maybe a gigantic boa constrictor which has swallowed an
elephant b see �����
The upper bound is obvious from the equalityPn
k��
�nk
�� �n� and
the lower bound follows from it as well� because� nbn��c
�is largest
among the n% � binomial coe�cients�nk
�whose sum is �n�
We prove a considerably more precise estimate� For convenient no�tation� we will only work with even values of n� and so we write n � �m�
����� Proposition� For all m � we have��m
�pm���m
m
�� ��mp
�m�
Proof� Both inequalities are proved similarly� Let us consider the num�ber
P �� � � � � � � � � � �m� �� � � � � � � � � � �m
the whole idea of the proof is hidden in this step� Since
P �� � � � � � � � � � �m� �� � � � � � � � � � �m � � � � � � � � � �m
� � � � � � � � �m ��m�
��mm���
we get
P ��
��m
��m
m
��
Thus� we want to prove
�
�pm� P � �p
�m�
For the upper bound� consider the product��� �
��
���� �
��
�� � �
��� �
�m�
��
��� Estimates� binomial coe�cients ��
which can be rewritten as�� � ���
��� � ���
�� � �
��m� ��m� �
�m�
�� �m� �P ��
Since the value of the product is less than �� we get �m � �P � � ��and hence P � ��p�m�For the lower bound we consider the product�
�� �
��
���� �
��
�� � �
��� �
�m� ����
and we express it in the form�� � ���
��� � ���
�� � �
��m� ��m�m� ��
��
�
� � �m � P ��
which gives the lower bound in Proposition ������ �
Let us remark that by approximating both �m� and m� using Stir�ling�s formula� we get a more precise result�
�m
m
�� ��mp
�m�
Such estimates have interesting relations with number theory� for ex�ample� One of the most famous mathematical theorems is the followingstatement about the density of primes�
����� Theorem Prime number theorem� Let �n denote thenumber of primes not exceeding the number n� Then
�n � n
lnn
�i�e� limn�� �n lnn�n � ���
Several proofs of this theorem are known� all of them quite di�cultand a quest for interesting variations and simpli�cations still contin�ues� Within the past century� Tschebyshev found a simple proof of thefollowing weaker result�
�n � "� n
lnn
��
i�e� c�n� lnn � �n � c�n� lnn holds for all n and for certain constants
c� c� � � Part of the proof is based on the estimates��m
�m�� ���mm
� ���m see Exercise �� Tschebyshev also proved the so�called Bertrandpostulate� For every n �� there exists a prime p with n � p � �n�Perhaps the simplest known proof uses� among others� the estimates inProposition ������ The reader can learn about these nice connections inChandrasekhar ����� for example�
�� Combinatorial counting
Exercises
�� a Prove the estimate�nk
� � en�kk by induction on k�b Prove the estimate in a directly from Theorem ������
�� Tschebyshev estimate of �n
a Show that the product of all primes p with m � p � �m is at most��mm
��
b �Using a� prove the estimate �n � On� lnn� where �n is asin the prime number theorem ������
c �Let p be a prime� and let m� k be natural numbers� Prove that ifpk divides
��mm
�then pk � �m�
d Using c� prove �n � !n� lnn�
��� Inclusionexclusion principleWe begin with a simple motivating example� As many authors of exam�ples with �nite sets have already done� we resort to a formulation withclubs in a small town�
����� Example� The town of N� has � clubs� The lawn�tennis club has� members� the chandelier collectors club �� members� and the mem�bership of the Egyptology club numbers �� There are � tennis playersand � chandelier collectors among the Egyptologists� � people both playtennis and collect chandeliers� and there is even one especially eager per�son participating in all three clubs� How many people are engaged inthe club life in N��
As a warm�up� let us count the combined membership of tennis andEgyptology� We see that we have to add the number of tennis playersand the Egyptology fans and subtract those persons who are in boththese clubs� since they are accounted for twice in the sum� Writtenin symbols� we have jT � Ej � jT j � jEj � jT � Ej � � � � � � ���� The reader who isn�t discouraged by the apparent silliness of thewhole problem� can probably �nd� with similar but more complicatedconsiderations� that the answer for the � clubs is ��� To �nd the answer�it may be helpful to draw a picture�
CT
E
�Which may indicate mathematical inclinations�
��� Inclusion�exclusion principle ��
The inclusion�exclusion principle mentioned in the section�s title isa formula which allows us to solve problems of a similar type for anarbitrary number of clubs� It is used in situations where we want tocompute the size of the union of several sets� and we know the sizesof all possible intersections of these sets� For � sets� T and E� sucha formula has been given above� and for � sets C� T�E it reads
jC�T �Ej � jCj% jT j% jEj�jCT j�jCEj�jT Ej% jCT Ej�Expressed in words� in order to get the size of the union� we �rst addup the sizes of all the sets� then we subtract the sizes of all pairwiseintersections� and �nally we add the size of the intersection of allthe � sets� As will be shown in a moment� such a method also worksfor an arbitrary number n of �nite sets A�� A�� � � � � An� The size oftheir union� i�e� jA� � A� � � � � � Anj� is obtained as follows� we addup the sizes of all the sets� then we subtract the sizes of all pairwiseintersections� add the sizes of all triple intersections� subtract thesizes of all ��wise intersections� etc�� as the last step� we either add�for n odd or subtract �for n even the size of the intersection of allthe n sets�
How do we write this in a formula� One attempt might be
jA� �A� � � � � �Anj � jA�j% jA�j% � � � % jAnj�jA�A�j� jA�A�j� � � ��jA�Anj� jA�A�j� � � ��jAn��Anj
%jA� A� A�j% jA� A� A�j% � � �% ���n��jA� A� � � � Anj�
This is a cumbersome and not very clear way of expressing such asimple rule� Slightly better is a notation using sums�
jA� �A� � � � � �Anj �nXi��
jAij �X
��i��i��njAi� Ai� j
%X
��i��i��i��njAi� Ai� Ai� j
� � � � % ���n��jA� A� � � � Anj�If we recall the notation
�Xk
�for the set of all k�element subsets of
a set X� and if we use a notation similar toP
also for multipleintersections and unions� we can write the same formula still moreelegantly�
�� Combinatorial counting
���� Theorem �Inclusion�exclusion principle�� For any col�
lection A�� A�� � � � � An of �nite sets� we have���� n�i��
Ai
���� � nXk��
���k��X
I��f��������ngk
���� �i�I
Ai
����� �����
In case you cannot see why this formula expresses the rule wehave formulated in words� you may want to devote some time to itand work out the case n � � in detail� Many students have problemswith this notation �or any mathematical notation for the inclusion�exclusion principle� confusing numbers with sets and vice versa� andthis makes a clean solution of more complicated problems very hard�
Finally� the shortest and almost devilish way of writing the inclusion$exclusion principle is���� n�
i��
Ai
���� � X���I�f��������ng
��jIj��
���� �iI
Ai
����� ����
First proof of the inclusion�exclusion principle� by induc
tion� The induction is on n� the number of sets� There is a smallsubtlety here� for the inductive step� we need the formula for thecase n � �� and so we use n � � as the basis for induction� For �sets� as we know� the formula holds� Assume its validity for arbitraryn� � sets� We have���� n�
i��
Ai
���� ������ n���
i��
Ai
��An
���� ����� n���i��
Ai
����% jAnj ������ n���
i��
Ai
�An
�����here we used inclusion�exclusion for � sets� i�e� the equality jA �Bj �jAj% jBj � jA Bj with A � A� � � � � �An��� B � An
�
���� n���i��
Ai
����% jAnj ����� n���i��
�Ai An
�����distributivity of the intersection� X �Y �Z � �X Y � �X Z�now we use the inductive hypothesis twice� once for jA��� � ��An��jand once for jA�� � � � � �A�n��j� where A�i � Ai An
�
� n��Xk��
���k��X
I��f��������n��gk
���� �i�I
Ai
�����% jAnj
��� Inclusion�exclusion principle ��
�� n��Xk��
���k��X
I��f��������n��gk
���� �i�I�fng
Ai
������
We are nearly done� In the �rst sum� we add� with the proper signs�the sizes of all intersections not involving the set An� In the secondsum� the sizes of all the intersections involving An appear� and theintersection of k % � sets �i�e� some k sets among A�� � � � � An�� plusAn has the sign ����k�� � ���k� The second sum doesn�t in�clude the term jAnj� but this appears separately between both sums�Altogether� the size of the intersection of any k�tuple of sets amongA�� � � � � An appears exactly once in the expression� with the sign���k��� This agrees with Eq� ������ and the proof by induction is�nished� Without a reasonable notation� we would easily get lost inthis proof� �
Second proof of the inclusion�exclusion principle� by count
ing� Let us consider an arbitrary element x � A� � � � � � An� Itcontributes exactly � to the size of the union on the left�hand sideof ������ Let us look at how much x contributes to the various in�tersection sizes on the right�hand side� Let j be the number of setsamong the Ai that contain x� We can rename the sets so that x iscontained in A�� A�� � � � � Aj �
The element x now appears in the intersection of every k�tupleof sets among A�� A�� � � � � Aj and in no other intersections� Sincethere are
�jk
�k�element subsets of a j�element set� x appears in
�jk
�intersections of k�tuples of sets� The sizes of k�wise intersections arecounted with the sign ���k��� and so x contributes the quantity
j ��j
�
�%
�j
�
�� � � � % ���j��
�j
j
�
to the right�hand side of the inclusion�exclusion formula ������ Bythe formula ���� for the sum of binomial coe�cients with alternat�ing signs� the above expression equals �� The contribution of eachelement x to both sides of the inclusion�exclusion formula ����� isthus �� and the formula is proved� �
And one more proof� If one looks at the inclusion$exclusion prin�ciple in a proper way� it is a consequence of the following formula forexpanding a product�
� Combinatorial counting
� � x�� � x� � � � � � xn �X
I�f��������ng
�YiI
xi
�� ����
Contemplate what this formula says write it out for n � �� �� �� sayand why it holds�In order to prove the inclusion$exclusion principle� let us denote
A � A� � A� � � � � � An� and let fi�A � f � �g be the characteristicfunction of the set Ai� which means that fia � � for a � Ai andfia � otherwise� For every a � A� we have
Qni��� � fia �
don�t we�� and using ���� with xi � �fia we getXI�f��������ng
��jIjYiI
fia � �
By adding all these equalities together for all a � A� and then by inter�changing the summation order� we arrive at
�XaA
� XI�f��������ng
��jIjYiI
fia
�
�X
I�f��������ng��jIj
�XaA
YiI
fia
�� ����
Now it su�ces to note that theQ
iI fia is the characteristic func�tion of the set
TiI Ai� and therefore
PaA
QiI fia �
��TiI Ai
��� Inparticular� for I � � Qi� fia is the empty product� with value �by de�nition� and so
PaA
Qi� fia �
PaA � � jAj� Hence ����
means
jAj�X
���I�f��������ng��jIj
���� �iI
Ai
���� � �and this is exactly the inclusion$exclusion principle� An expert in al�gebra can thus regard the inclusion$exclusion principle with mild con�tempt� a triviality� she might say� �
Bonferroni inequalities� Sometimes we can have the situation wherewe know the sizes of all the intersections up to m�fold ones� but wedo not know the sizes of intersections of more sets than m� Then wecannot calculate the size of the union of all sets exactly� The so�calledBonferroni inequalities tell us that if we leave out all terms with k � mon the right�hand side of the inclusion$exclusion principle ���� thenthe error that we make in this way in the calculation of the size of theunion has the same sign as the �rst omitted term� Written as a formula�for every even q we have
qXk��
��k��X
If��������ngk
���� �iI
Ai
���� ����� n�i��
Ai
���� ����
��� The hatcheck lady � co� ��
and for every odd q we have
qXk��
��k��X
If��������ngk
�����iI
Ai
���� ���� n�i��
Ai
����� ���
This means� for instance� that if we didn�t know how many diligentpersons are simultaneously in all the three clubs in Example ������ wecould still estimate that the total number of members in all the clubsis at least ��� We do not prove the Bonferroni inequalities here�
Exercises
�� Explain why the formulas ���� and ���� express the same equality�
�� �Prove the Bonferroni inequalities� If you cannot handle the generalcase try at least the cases q � � and q � ��
�� Sieve of Eratosthenes How many numbers are left in the setf�� �� � � � � � g after all multiples of �� �� �� and � are crossed out�
�� How many numbers n � � are not divisible by a square of any integergreater than ��
�� �How many orderings of the letters A� B� C� D� E� F� G� H� I� J� K�L� M� N� O� P are there such that we cannot obtain any of the wordsBAD� DEAF� APE by crossing out some letters� What if we also forbidLEADING�
�� How many ways are there to arrange � Americans� � Russians� and �Chinese into a queue� in such a way that no nationality forms a singleconsecutive block�
��� The hatcheck lady � co�
����� Problem �Hatcheck lady problem�� Honorable gentle�men� n in number� arrive at an assembly� all of them wearing hats�and they deposit their hats in a cloak�room� Upon their departure�the hatcheck lady� maybe quite absent�minded that day� maybe evenalmost blind after many years of service in the poorly lit cloak�room�issues one hat to each gentleman at random� What is the probabilitythan none of the gentlemen receives his own hat�
As stated� this is a toy problem� but mathematically it is quite re�markable� and a few hundred years back� it occupied some of the bestmathematical minds of their times� First we reformulate the prob�lem using permutations� If we number the gentlemen �our apologies
�� Combinatorial counting
�� �� � � � � n� and their hats too� then the activity of the hatcheck ladyresults in a random permutation � of the set f�� �� � � � � ng� where ��iis the number of the hat returned to the ith gentleman� The questionis� what is the probability of ��i � i holding for all i � f�� �� � � � � ng�Call an index i with ��i � i a xed point of the permutation �� Sowe ask� what is the probability that a randomly chosen permutationhas no �xed point� Each of the n� possible permutations is� accordingto the description of the hatcheck lady�s method of working� equallyprobable� and so if we denote by D�n the number of permutationswith no �xed point on an n�element set� the required probabilityequals D�n�n��
Using the inclusion�exclusion principle� we derive a formula forD�n� We will actually count the �bad� permutations� i�e� thosewith at least one �xed point� Let Sn denote the set of all permu�tations of f�� �� � � � � ng� and for i � �� �� � � � � n� we de�ne Ai � f� �Sn� ��i � ig� The bad permutations are exactly those in the unionof all the Ai�
Here we suggest that the reader contemplate the de�nition of thesets Ai carefully�it is a frequent source of misunderstandings theirelements are permutations� not numbers�
In order to apply the inclusion�exclusion principle� we have toexpress the size of the k�fold intersections of the sets Ai� It is easyto see that jAij � �n���� because if ��i � i is �xed� we can choosean arbitrary permutation of the remaining n � � numbers� Whichpermutations lie in A� A�� Just those with both � and � as �xedpoints �and the remaining numbers can be permuted arbitrarily� andso jA�A�j � �n���� More generally� for arbitrary i� � i� � � � � � ikwe have jAi� Ai� � � � Aik j � �n� k�� and substituting this intothe inclusion�exclusion formula yields
jA� � � � � �Anj �nX
k��
���k���n
k
��n� k� �
nXk��
���k��n�k��
We recall that we have computed the number of bad permutations�with at least one �xed point� and so
D�n � n�� jA� � � � � �Anj � n�� n�
��%n�
��� � � �% ���nn�
n��
which can still be rewritten as
�Such permutations are sometimes called derangements�
��� The hatcheck lady � co� ��
D�n � n�
��� �
��%
�
��� � � �% ���n �
n�
�� �����
As is taught in calculus� the series in parentheses converges to e��
for n � � �where e is the Euler number� and it does so veryfast� So we have the approximate relation D�n � n��e� and theprobability in the hatcheck lady problem converges to the constante�� � ������� � � �� This is what also makes the problem remarkable�the answer almost doesn�t depend on the number of gentlemen�
The Euler function �� A function denoted usually by � and namedafter Leonhard Euler plays an important role in number theory� For anatural number n� the value of �n is de�ned as the number of naturalnumbers m � n that are relatively prime to n� formally
�n � jfm � f�� �� � � � � ng� gcdn�m � �gj �
Here gcdn�m denotes the greatest common divisor of n andm� that is�the largest natural number that divides both n and m� As an exampleof application of the inclusion$exclusion principle� we �nd a formulawhich allows us to calculate �n quickly provided that we know thefactorization of n into prime factors�The simplest case is when n � p is a prime� Then every m � p is
relatively prime to p� and so �p � p� ��The next step towards the general solution is the case when n � p�
� � N is a prime power� Then the numbers not relatively prime top� are multiples of p� i�e� p� �p� �p� � � � � p���p� and there are p��� suchmultiples not exceeding p� in general� if d is an any divisor of somenumber n� then the number of multiples of d not exceeding n is n�d�Hence� there are �p� � p� � p��� � p��� ��p remaining numbersthat are relatively prime to p��An arbitrary n can be written in the form
n � p��� p��� � � � p�rr �
where p�� p�� � � � � pr are distinct primes and �i � N� The �bad� m � n�i�e� those not contributing to �n� are all multiples of some of theprimes pi� Let us denote by Ai � fm � f�� �� � � � � ng� pijmg the setof all multiples of pi� We have �n � n � jA� � A� � � � � � Arj� Theinclusion$exclusion principle commands that we �nd the sizes of theintersections of the sets Ai� For example� the intersection A� �A� con�tains the numbers divisible by both p� and p�� which are exactly themultiples of p�p�� and hence jA� �A�j � n�p�p�� The same argumentgives
jAi� � Ai� � � � � �Aik j �n
pi�pi� � � � pik�
�� Combinatorial counting
Let us look at the particular cases r � � and r � � �rst� For n � p��� p���we have
�n � n� jA� � A�j � n� jA�j � jA�j� jA� � A�j
� n� n
p�� n
p��
n
p�p�� n
��� �
p�
���� �
p�
��
Similarly� for n � p��� p��� p��� we get
�n � n� n
p�� n
p�� n
p��
n
p�p��
n
p�p��
n
p�p�� n
p�p�p�
� n
��� �
p�
���� �
p�
���� �
p�
��
This may raise a suspicion concerning the general formula�
�� �� Theorem� For n � p��� p��� � � � p�rr � we have
�n � n
��� �
p�
���� �
p�
�� � �
��� �
pr
�� ����
Proof� For an arbitrary r� the inclusion$exclusion principle we use�to our advantage� the short formula ���� gives
�n � n�X
���I�f��������rg��jIj�� nQ
iI pi� n �
XI�f��������rg
��jIjQiI pi
�
We claim that this frightening formula equals the right�hand side ofEq� ����� This follows from the formula ���� for expanding the prod�uct ��x���x���x� � � � by substituting xi � ���pi� i � �� �� � � � � r�
�
Exercises
�� There are n married couples attending a dance� How many ways arethere to form n pairs for dancing if no wife should dance with herhusband�
�� a Determine the number of permutations with exactly one �xedpoint�
b Count the permutations with exactly k �xed points�
�� What is wrong with the following inductive �proof� that Dn �n� �� for all n �� Can you �nd a false step in it� For n ��� the formula holds� so assume n �� Let � be a permutation off�� �� � � � � n� �g with no �xed point� We want to extend it to a per�mutation �� of f�� �� � � � � ng with no �xed point� We choose a number
��� The hatcheck lady � co� ��
i � f�� �� � � � � n� �g� and we de�ne ��n � �i� ��i � n� and ��j ��j for j �� i� n� This de�nes a permutation of f�� �� � � � � ng� and it is easyto check that it has no �xed point� For each of the Dn� � � n� ��possible choices of �� the index i can be chosen in n� � ways� Therefore�Dn � n� �� � n� � � n� ���
�� �Prove the equation
Dn � n�� nDn� ���n
�
�Dn� �� � � � �
�n
n� ��D�� ��
�� a �Prove the recurrent formula Dn � n���Dn���Dn����Prove the formula ���� for Dn by induction�
b �Calculate the formula for Dn directly from the relation derivedin a� Use an auxiliary sequence given by an � Dn� nDn� ��
�� How many permutations of the numbers �� �� � � � � � exist that map noeven number to itself�
�� Number of mappings onto Now is the time to calculate the numberof mappings of an n�element set onto an m�element set note that wehave avoided it so far� Calculate them
a for m � �
b for m � ��
c �Write a formula for a general m� check the result for m � n � � what is the result for n � m�� Warning� The resulting formula is asum� not a �nice� formula like a binomial coe�cient�
d �Show� preferably without using part c� that the number of map�pings onto an m�element set is divisible by m��
�� a �How many ways are there to divide n people into k groups or�how many equivalences with k classes are there on an n�element set�Try solving this problem for k � �� � and k � n� �� n� � �rst� For ageneral k� the answer is a sum�
b What is the total number of equivalences on an n�element set�Here the result is a double sum�
c �If we denote the result of b by Bn the nth Bell number� provethe following surprising formula�
Bn ��
e
�Xi��
in
i��
�� �Prove the formula ���� for the Euler function in a di�erent way�Suppose it holds for n � p� a prime power� Prove the followingauxiliary claim� if m�n are relatively prime� then �mn � �m�n�
�� Combinatorial counting
� � �For an arbitrary natural number n� prove thatP
djn �d � n the
sum is over all natural numbers d dividing n�
��� a How many divisors does the number n � p��� p��� � � � p�rr havep�� p�� � � � � pr are distinct primes�
b Show that the sum of all divisors of such a number n equals
rYi��
p�i�� � �pi � � �
c ��Call a number n perfect if it equals the sum of all its divisorsexcluding itself� For example� � � � � � � � is perfect� Prove thatevery even perfect number has the form �q�q�� � �� where q � isa natural number and �q�� � � is a prime�Remark� No odd perfect numbers are known but no one can show thatthey don�t exist�
��� a �For a given natural number N � determine the probability thattwo numbers m�n � f�� �� � � � � Ng chosen independently at randomare relatively prime�
b �Prove that the limit of the probability in a for N � � equalsthe in�nite product
Qp�� ��p�� where p runs over all primes� Let
us remark that the value of this product is ����� this can be provedfrom Fact � �����
��� a Determine the number of graphs with no vertices of degree on agiven n�element vertex set V see Sections ��� and ��� for the relevantde�nitions�
b Determine the number of all graphs with at least � vertices ofdegree on V � and with exactly � vertices of degree �
��� �How many ways are there to seat n married couples at a round tablewith �n chairs in such a way that the couples never sit next to eachother�
�
Graphs� an introduction
��� The notion of a graph isomorphism
Many situations in various practically motivated problems and alsoin mathematics and theoretical computer science can be captured bya scheme consisting of two things�
� a ��nite set of points� and
� lines joining some pairs of the points�
For example� the points may represent participants at a birthdayparty and the joins correspond to pairs of participants who knoweach other� Or the points can represent street crossings in a city andthe joins the streets� Also a municipal transport network or a railwaynetwork is usually displayed as a scheme of this type �see Fig� ����and electrotechnical schemes often have a similar character as well�In such cases� the points are commonly called vertices �or also nodesand the joins are called edges��
If we disregard the length� shape� and other properties of thejoins and we only pay attention to which pairs of points are joinedand which are not� we arrive at the mathematical notion of a graph�Although very simple� a graph is one of the key concepts in discretemathematics� This is also illustrated in the subsequent sections�
����� De�nition� A graph� G is an ordered pair �V�E� where V is
some set and E is a set of ��point subsets of V � The elements of theset V are called vertices of the graph G and the elements of E edgesof G�
�The origins of this terminology are mentioned in Section �����What we simply call a graph here is sometimes more verbosely called a simple
undirected graph� in order to distinguish it from other� related notions� Some ofthem will be mentioned later�
�� Graphs� an introduction
Praha
Vran�en� Vlt�
Dob r�� s
Hostivice
Zdice
Lochovice
Sedl canyOlbramovice
Cer cany
Lede cko
Kladno
Rakovn��k
Krup�a
Zatec
Kou rim
Be cv�ary
Bo sice
Pe cky Velk�y Osek
Kol��n
Kutn�a Hora
C�aslav
Chlumec
Ostrom e r
K rinec
Kopidlno
Po r�� cany
M eln��k
Lu zecn� Vlt�
V setaty
Neratovice
Mochov Cel�akovice
MiloviceVele�liby
Mlad�aBoleslav
Bakov n� JizerouDoln��Bousov
Ji c��n
Libu n
Star�aPaka
Zlonice
Libochovice
Stra skovLouny
Louny�p redm est��
Podle s��nKralupyn� Vlt�
Vra� nany
Kole� sovice
T remo s�nice
n� Cidl�
Roudnicen� L�
Vel�vary
Lys�a n�L�
Zadn��T reba n
Beroun�Z�avod��
Beroun
Lu zn�au Rakovn��ka
Zru cn� S�az�
Sv etl�an� S�az�
Bene sovu Prahy
P r��bramVla sim
Cesk�yBrod
Slan�y
Nymburk�hl� n�
Nymburk�m esto
Trhov�y St ep�anov
Posto�loprty
Rudn�au Prahy
Fig� ��� A scheme of part of the Czech railway network in a region of
about �� � � km around Prague�
In this book� we almost always consider graphs with �nite vertexsets� The few cases where we deal with in�nite graphs too will bementioned explicitly�
If we want to point out that some graph G has V as the vertexset and E as the edge set we write G � �V�E� If we talk about someknown graph G and we want to refer to its vertex set� we denote itby V �G� Similarly we write E�G for the edge set of G� A usefulnotation is also
�V�
�for the set of all ��element subsets of V �see
Section ����� for a motivation of this symbol� We can brie y saythat a graph is a pair �V�E� where E � �V
�
��
The following terminology is fairly self�explanatory� if fu� vg is anedge of some graph G� we say that the vertices u and v are adjacentin G or that u is a neighbor of v �and v is a neighbor of u�
Graphs are usually depicted by drawings in the plane� The ver�tices of a graph are assigned points in the plane �drawn as dots�bullets� little circles� etc� and the edges are expressed by connect�ing the corresponding pairs of points by straight or variously curvedlines �these lines are called arcs in this context� In this way� we getpictures like this�
��� The notion of a graph� isomorphism ��
The word graph itself perhaps comes from the possibility of sucha drawing� �We should emphasize that the word graph is used herewith a di�erent meaning than in �graph of a function�we sincerelyhope that the reader has noticed this by now�
The role of the drawing of a graph is auxiliary� however� A graphcan also be represented in many other ways� and� for instance� in acomputer memory it is certainly not stored as a picture� One graphcan be drawn in many di�erent ways� For example� the �rst two ofthe above pictures show the same graph with vertex set f�� �� �� �� �gand edges f�� �g� f�� �g� f�� �g� f�� �g� f�� �g�
In a visually well�arranged drawing of a graph� the arcs should�cross� as little as possible� Crossings could possibly be mistakenfor vertices� and also in some schemes of electronic circuits and in anumber of other situations crossings are inadmissible� This leads tothe study of an important class of the so�called planar graphs �seeChapter ��
Drawing graphs is an important aid in the theory of graphs� Drawpictures for yourself whenever possible� Many notions are motivated�pictorially� and drawings can make such notions much more intu�itive�
The railway scheme in Fig� ��� also illustrates that the notion ofa graph is a nontrivial abstraction and simpli�cation of real life situa�tions� The arcane and historically developed railway network shown inthe �gure resembles a graph drawing� but� for example� there are fewplaces where tracks branch outside of railway stations� Also� there areplenty of other types of information one might want to associate witha railway network scheme track quality and number for each connec�tion� which tracks go straight through a station and which form a sidebranch� station distances� train schedules� and so on� If one should makea mathematical model of a railway network and didn�t know the notionof a graph� one would probably come up with something much morecomplex� In applications� graphs are indeed often augmented by furtherinformation� But the notion of a graph is very useful as a �skeleton�of such mathematical models� and once we use a graph as a signi�cantpart of the model� we immediately have a well�developed mathemati�cal theory at our disposal� suggesting further notions� properties� ande�cient algorithms to consider�
� Graphs� an introduction
Important graphs� We introduce several types of speci�c graphs�which are quite often encountered in graph theory and for whichstandard notation and terminology have become customary�
The complete graph Kn V � f�� �� � � � � ng� E ��V�
��
K� K�K� K
Mainly for aesthetic reasons� we also include a drawing of K�� withall of its ��� edges�
The cycle Cn V � f�� �� � � � � ng� E � ffi� i%�g� i � �� �� � � � � n� �g�ff�� ngg�
C� C� C� C
The path Pn V � f�� �� � � � � ng� E � ffi� �� ig� i � �� �� � � � � ng�
��� The notion of a graph� isomorphism ��
P
The complete bipartite graph Kn�m
V � fu�� � � � � ung � fv�� � � � � vmg�E � ffui� vjg� i � �� �� � � � � n� j � �� �� � � � �mg�
K��� K��� K��� K��� K���
A small explanation seems appropriate here� The word �bipartite�means �consisting of two parts�� In general� a graph G is calledbipartite if the set V �G can be divided into two disjoint sets V� andV� in such a way that each edge of G connects a vertex from V� toa vertex from V�� Written in symbols� E�G � ffv� v�g� v � V�� v
� �V�g� Such sets V� and V� are sometimes called the classes of G� butnot �partites�� however tempting this neologism may be�
Graph isomorphism� Two graphs G and G� are considered iden�tical �or equal if they have the same set of vertices and the sameset of edges� i�e� G � G� means V �G � V �G� and E�G � E�G��But many graphs di�er �only� by the names of their vertices andedges and have the same �structure�� This is captured by the notionof isomorphism�
����� De�nition� Two graphs G � �V�E and G� � �V �� E� are
called isomorphic if a bijection f �V � V � exists such that
fx� yg � E if and only if ff�x� f�yg � E�
holds for all x� y � V � x � y� Such an f is called an isomorphismof the graphs G and G�� The fact that G and G� are isomorphic is
written G �� G��
An isomorphism is thus required to map adjacent vertices to ad�jacent vertices and nonadjacent vertices to nonadjacent vertices� andit can be thought of as �renaming the vertices� of a graph� The rela�tion �� ��to be isomorphic� is an equivalence� on any set of graphs�see Exercise ��
Problem� The following three pictures show isomorphic graphs�Show this by �nding suitable isomorphisms�
�� Graphs� an introduction
a b c
d e f
��
�
�
�
�
�
���
�
�
Solution� All the three graphs are isomorphic to K���� An isomor�phism of the �rst graph to the second graph� for instance� � �� a�� �� d� � �� b� � �� e� � �� c� � �� f �several other possibilities exist��The others are left to the reader�
Warning� The de�nition of isomorphism looks easy but many studentstend to mess it up� They often think that an isomorphism of G to G� isany bijection between E and E� etc� As a precaution� it is best to trywriting the de�nition down without looking in the textbook�
Testing isomorphism� For small pictures� it is usually not too di��cult to �nd out whether they correspond to isomorphic graphs or notalthough the preceding problem indicates that the pictures need notlook the same at all� But the problem of deciding whether two givengraphs are isomorphic or not is di�cult in general� and no e�cient al�gorithm is known for it i�e� one working fast in all cases� It is evensuspected that no such e�cient algorithm exists� Roughly speaking� thedi�culty lies in showing that two given graphs on n vertices are not iso�morphic� To check this according to the de�nition� we must verify thatnone of the possible n� bijections of the vertex sets is an isomorphism�Of course� often we can use a shortcut and exclude the possibility of anisomorphism right away� For instance� if the numbers of edges di�er� thegraphs cannot be isomorphic because isomorphism preserves the num�ber of edges� More generally� if we can assign some number� vector� etc��to a graph in such a way that isomorphic graphs are always assignedthe same value� we can sometimes use this to distinguish nonisomorphicgraphs examples will be discussed later� But so far no fast method hasbeen found that would always succeed in distinguishing nonisomorphicgraphs�
Number of nonisomorphic graphs� Let V be the set f�� �� � � � � ng�To choose a graph with vertex set V means choosing an arbitrary subsetE � �
V�
�� The set
�V�
�has
�n�
�elements� and thus the number of di�erent
graphs on V is exactly �n
�� However� there are considerably fewer than
�n
� pairwise nonisomorphic graphs with n vertices� For example� for
V � f�� �� �g we get the following � � ��� distinct graphs�
��� The notion of a graph� isomorphism ��
� �
�
� �
�
� �
�
� �
�
� �
�
� �
�
� �
�
� �
�
Among these � possibilities� only � nonisomorphic ones can be found�
How many pairwise nonisomorphic graphs on n vertices exist for ageneral n� In other words� how many classes of the equivalence rela�tion �� on the set of all graphs with vertex set V � f�� �� � � � � ng arethere� Determining this number exactly is not easy see e�g� Hararyand Palmer ����� but we can at least get a reasonable estimate bya simple but clever� trick� On the one hand� the number of noniso�morphic graphs on n vertices is certainly not larger than the number of
all distinct graphs on the set V � i�e� �n
�� On the other hand� considera particular graph G with vertex set V � How many distinct graphs G�
on V are isomorphic to it� For instance� if G is the graph
� �
�
on the vertex set f�� �� �g� there are � such isomorphic graphs� By def�inition� if G� is such a graph isomorphic to G� there exists a bijectionf �V � V that is an isomorphism of G and G�� The number of all pos�sible bijections f �V � V is n�� and hence G is isomorphic to at most n�distinct graphs on the set V � We may be overcounting� For our speci�cexample for n � �� we had �� � � bijections but only � distinct graphsisomorphic to G�can you explain why� In other words� each class ofthe equivalence �� on the set of all graphs with vertex set V consists ofno more than n� graphs� and therefore the number of equivalence classesis at least
�n
�
n��
Consequently� there is a collection of at least this many pairwise non�isomorphic graphs on n vertices�We claim that this function of n doesn�t grow much more slowly
than �n
�� To see this� we take the logarithms of both functions andmanipulate the resulting expressions somewhat� We use the obviousestimate n� � nn�
log�
h�
n
�i�
�n
�
��n�
�
��� �
n
��
�� Graphs� an introduction
log��
n
�
n��
�n
�
�� log� n�
�
�n� � �
�n� n log� n
�n�
�
��� �
n� � log� n
n
��
We see that for large n� the logarithms of both functions behave �roughlyas� the function �
�n�� the relative error we would make by replacing their
logarithms by ��n
� goes to for n � �� Section ��� says more aboutestimating the growth of functions� In particular� if n is su�cientlylarge� the number of nonisomorphic graphs on n vertices is much muchlarger than �n� say�In the consideration just made� we have only shown that many non�
isomorphic graphs exist� but� remarkably� we have constructed no spe�ci�c collection of such graphs� Similar methods will be discussed moresystematically in Chapter �� Constructing many nonisomorphic graphsexplicitly is not so easy�see Exercise ��
Exercises
�� a Find an isomorphism of the following graphs�
b Show that both the graphs above are isomorphic to the following
graph� the vertex set is�f���������g
�
�unordered pairs of numbers� and
two vertices fi� jg and fk� �g i� j� k� � � f�� �� � � � � �g form an edge ifand only if fi� jg � fk� �g � �Remark� This graph is called the Petersen graph and it is one ofthe most remarkable small graphs being a counterexample to numer�ous conjectures� an exceptional case in many theorems� etc�� It is thesmallest nontrivial member of a family of the so�called Kneser graphs�which supplies many more examples of graphs with interesting proper�ties� The vertex set of a Kneser graph is
�f��������ngk
�for natural numbers
n � k �� and edges correspond to empty intersections��� An automorphism of a graph G � V�E is any isomorphism of Gand G� i�e� any bijection f �V � V such that fu� vg � E if and onlyif ffu� fvg � E� A graph is called asymmetric if its only automor�phism is the identity mapping each vertex is mapped to itself�
��� The notion of a graph� isomorphism ��
a Find an example of an asymmetric graph with at least � vertices�
b Show that no asymmetric graph G exists with � � jV Gj � ��
�� Show that a graph G with n vertices is asymmetric see Exercise � ifand only if n� distinct graphs on the set V G are isomorphic to G�
�� Call a graph G � V�E vertex�transitive if for any two vertices v� v� �V an automorphism f �V � V of G exists see Exercise � with fv �v�� Similarly� G is edge�transitive if for any two edges e� e� � E anautomorphism f �V � V exists with fe � e� if e � fu� vg then thenotation fe stands for the set ffu� fvg�a Prove that the graph in Exercise � is vertex�transitive�
b Decide whether each vertex�transitive graph is edge�transitive aswell�
c Find a graph that is edge�transitive but not vertex�transitive�
d �Show that any graph as in c is necessarily bipartite�
�� How many graphs on the vertex set f�� �� � � � � �ng are isomorphic tothe graph consisting of n vertex�disjoint edges i�e� with edge setff�� �g� f�� �g� � � � � f�n� �� �ngg�
�� Let V be a �nite set� Let G denote the set of all possible graphs withvertex set V � Verify that �� �to be isomorphic� is an equivalencerelation on G�
�� Construct as many pairwise nonisomorphic graphs with vertex setf�� �� � � � � ng as possible suppose that n is a very large number� Canyou �nd more than n� of them� At least �n���� or even substantiallymore�
�� a CS Plot the logarithms of the functions �n
� and �n
��n� in a suit�able range�
b ��CS Write a computer program for calculating the number of non�isomorphic graphs on n vertices for a given n� Warning� Unless youdevise a clever method� you will only be able to deal with very smallvalues of n�� For the values of n you can handle� draw the actualnumbers on the plot made in a�
c �If you were able to solve b cleverly� the numbers should indicatethat the lower bound �
n
��n� for the number of nonisomorphic graphs
is much closer to the truth than the upper bound �n
�� The upperbound was gained by a quite trivial method anyway� can you improveit�
�� Graphs� an introduction
a
b
�a �b
Fig� ��� An example of a subgraph a� and of an induced subgraph b�
��� Subgraphs� components� adjacency matrix
The next de�nition captures the intuitive notion of �one graph beingcontained in another graph�� It turns out there are at least two waysof making this precise�
����� De�nition� Let G and G� be graphs� We say that G is a
subgraph of G� if V �G � V �G� and E�G � E�G��We say that G is an induced subgraph of G� if V �G � V �G� and
E�G � E�G� �V �G �
��
This de�nition can also be rephrased as follows� an induced sub�graph of a graph G� arises by deleting some vertices of G� and alledges containing a deleted vertex� To get a subgraph� we can alsodelete some more edges although none of their end�vertices has beendeleted� Fig� ����a shows a graph and its subgraph isomorphic tothe path P� drawn by a thick line� This subgraph is not induced�because of the edge fa� bg� Fig� ����b shows an induced subgraph�isomorphic to the cycle C�� this is a subgraph as well� of course�
Paths and cycles� A subgraph of a graph G isomorphic to somepath Pt is called a path in the graph G� see Fig� ����a� A path in agraph G can also be understood as a sequence
�v�� e�� v�� � � � � et� vt�
where v�� v�� � � � � vt are mutually distinct vertices of the graph G�and for each i � �� �� � � � � t we have ei � fvi��� vig � E�G� This islike the log of a traveler who followed the path from one end to theother end and recorded the visited vertices and edges�� We also say
�Since we only consider simple graphs� recording the edges is not really nec�essary� as they can be reconstructed from the sequence of vertices� The de�nitionwe use is advantageous if multiple edges connecting two vertices are allowed�
��� Subgraphs� components� adjacency matrix ��
that the path �v�� e�� v�� � � � � et� vt is a path from v� to vn of length t�Let us remark that we also allow t � �� i�e� a path of zero lengthconsisting of a single vertex�
Similarly� a subgraph of G isomorphic to some cycle Ct �t � � iscalled a cycle in the graph G� see Fig� ����b� �An alternative nameused in the literature is a circuit� A cycle in a graph G can also beunderstood as a sequence
�v�� e�� v�� e�� � � � � et��� vt��� et� v�
�the initial and �nal points coincide� where v�� v�� � � � � vt�� are pair�wise distinct vertices of the graph G� and ei � fvi��� vig � E�Gfor i � �� �� � � � � t� �� and also et � fvt��� v�g � E�G� The numbert � � is the length of the cycle�
Connectedness� components� We say that a graphG is connectedif for any two vertices x� y � V �G� G contains a path from x to y�Diagram �a shows an example of a connected graph�
a b
while �b is a drawing of a disconnected graph�The notion of connectedness can also be de�ned slightly di�er�
ently� First we de�ne a notion similar to a path in a graph� LetG � �V�E be a graph� A sequence �v�� e�� v�� e�� � � �� et� vt is calleda walk in G �more verbosely� a walk of length t from v� to vt if wehave ei � fvi��� vig � E for all i � �� � � � � t� In a walk some edgesand vertices may be repeated� while for a path this was forbidden�A walk is the log of a leisurely traveler who doesn�t mind visitingedges or vertices several times�
Next� we de�ne a relation � on the set V �G by letting x � yif and only if there exists a walk from x to y in G� It is a fairlyeasy exercise to check that � is an equivalence relation� Let V �V� &�V� &� � � � &�Vk be a partition of the vertex set V into classes of theequivalence �� The subgraphs of G induced by the sets Vi are calledthe components of the graph G� The following observation relates thede�nition of components to the previous de�nition of a connectedgraph�
�� Graphs� an introduction
����� Observation� Each component of any graph is connected�
and a graph is connected if and only if it has a single component�
Proof� Clearly� a connected graph has a single component� On theother hand� any two vertices x� y in the same component of a graphG can be connected by a walk� Any walk from x to y of the shortestpossible length must be a path� �
Why did we choose the somewhat roundabout de�nition of compo�nents using walks� rather than using paths� We could de�ne the com�ponents using the relation ��� where x �� y if a path from x to y exists�The above considerations show that �� is in fact the same relation as�� But showing directly that �� is an equivalence is a bit messy� andthe approach via walks seems cleaner�
It is relatively easy to decide whether a given graph is connected�or to �nd the components� We aren�t going to describe such algorithmshere� they can be found in almost any textbook on algorithms� Theyare usually presented as algorithms for searching a graph� or a maze�One such algorithm is the so�called depth��rst search�
Distance in graphs� Let G � �V�E be a connected graph� Wede�ne the distance of two vertices v� v� � V �G� denoted by dG�v� v
��as the length of a shortest path from v to v� in G�
Hence dG is a function� dG�V �V � R� and it is called the distancefunction or the metric of the graph G� The metric of G has the followingproperties�
�� dGv� v� � and dGv� v� � if and only if v � v��
�� symmetry dGv� v� � dGv
�� v for any pair of vertices v� v���� triangle inequality dGv� v
�� � dGv� v��dGv�� v�� for any three
vertices v� v�� v�� � V G�
The validity of these statements can be readily checked from the de��nition of the distance function dGv� v
�� Each mapping d�V � V � Rwith properties �$� is called a metric on the set V � and the set V to�gether with such a mapping d is called a metric space� The distancefunction dG of a graph has� moreover� the following special properties�
�� dGv� v� is a nonnegative integer for any two vertices v� v��
�� if dGv� v�� � � then there exists a vertex v�� v �� v� �� v��� such
that dGv� v� � dGv
�� v�� � dGv� v���
Conditions �$� already characterize functions arising as distancefunctions of graphs with vertex set V see Exercise ��
Graph representations� We have seen representations of graphsby drawings� and also by writing out a list of vertices and edges�
��� Subgraphs� components� adjacency matrix ��
Graphs can also be represented in many other ways� Some of thembecome particularly important if we want to store and manipulategraphs in a computer� A very basic and very common representationis by an adjacency matrix�
����� De�nition� Let G � �V�E be a graph with n vertices� De�
note the vertices by v�� v�� � � � � vn �in some arbitrary order�� The ad�jacency matrix of G� with respect to the chosen vertex numbering�
is an n n matrix AG � �aijni�j�� de�ned by the following rule�
aij �
�� if fvi� vjg � E� otherwise�
This is very similar to the adjacency matrix of a relation de�nedin Section ���� The adjacency matrix of a graph is always a symmetricsquare matrix with entries � and �� with �s on the main diagonal�Conversely� each matrix with these properties is the adjacency matrixof some graph�
Example� The graph G �
�
�
�
�
��
has the adjacency matrix
AG �
�BBBBBBB
� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �
CCCCCCCA�
Let us emphasize that the adjacency matrix also depends on thechosen numbering of the vertices of a graph�
It might seem that we gain nothing new by viewing a graph asa matrix since the graph and the adjacency matrix both encode the
�� Graphs� an introduction
same information� To illustrate that we can pro�t from this alterna�tive representation� let us show a simple connection between matrixmultiplication and the graph metric�
����� Proposition� Let G � V�E be a graph with vertex set V �fv�� v�� � � � � vng and let A � AG be its adjacency matrix� Let Ak denotethe kth power of the adjacency matrix �the matrices are multipliedas is usual in linear algebra� i�e� if we put B � A�� we have bij �Pn
k�� aikakj�� Let a�k�ij denote the element of the matrix Ak at position
i� j� Then a�k�ij is the number of walks of length exactly k from the
vertex vi to the vertex vj in the graph G�
Proof� This is easy but very instructive� We proceed by inductionon k� A walk of length � between two vertices means exactly that thesevertices are connected by an edge� and hence for k � � the propositionjust reformulates the de�nition of the adjacency matrix�Next� let k � �� and let vi� vj be two arbitrary vertices possibly
identical� Any walk of length k from vi to vj consists of an edge fromvi to some neighbor v� of vi and a walk of length k � � from v� to vj �
vi
v�vj
By the inductive hypothesis� the number of walks of length k � � fromv� to vj is a
�k����j � Hence the number of walks of length k from vi to vj
is Xfvi�v�gE�G�
a�k����j �
nX���
ai�a�k����j �
But this is exactly the element at position i� j in the product of the
matrices A and Ak��� i�e� a�k�ij � �
����� Corollary� The distance of any two vertices vi� vj satis es
dGvi� vj � minfk �� a�k�ij �� g�
This result has surprising applications� For instance� if one wantsto �nd the distance for all pairs of vertices in a given graph� one canapply sophisticated algorithms for matrix multiplication some of themare described in Aho� Hopcroft� and Ullman ��� and some other ideasand get unexpectedly fast methods for computing the function dG� Ex�ercises � and �� indicate other algorithmic applications�
Let us remark that the adjacency matrix is not always the bestcomputer representation of a graph� Especially if a graph has fewedges �much fewer than
�n�
�� it is usually better to store the list
��� Subgraphs� components� adjacency matrix ���
of neighbors for every vertex� For a fast implementation of certainalgorithms� other� more complicated representations are used as well�
Exercises
�� Prove that the complement of a disconnected graph G is connected�The complement of a graph G � V�E is the graph V�
�V�
� nE��� What is the maximum possible number of edges of a graph with nvertices and k components�
�� CS Design an algorithm that �nds the decomposition of a given graphG into its components� Try to get an algorithm which needs at mostOn�m steps for a graph with n vertices and m edges�
�� �Prove that a graph is bipartite if and only if it contains no cycle ofan odd length�
�� �Describe all graphs containing no path not necessarily induced� oflength ��
�� �Having solved the preceding exercise� describe all graphs containingno path of length ��
�� Show that if a function d�V � V � N satis�es conditions �$� abovethen a graph G � V�E exists such that dGv� v
� � dv� v� for anypair of elements of V �
�� De�ne the �diameter� and �radius� of a graph in analogy with theintuitive meaning of these notions�
�� a Find a connected graph of n vertices for which each of the powersA�G� A
�G� � � � of the adjacency matrix contains some zero elements�
b Let G be a graph on n vertices� A � AG its adjacency matrix� andInthe n�n identity matrix with �s on the diagonal and s elsewhere�Prove that G is connected if and only if the matrix In � An�� hasno s�
c Where are the s in the matrix In � An�� if the graph G is notconnected�
� � Show that a graph G contains a triangle i�e� a K� if and only if thereexist indices i and j such that both the matrices AG and A
�G have the
entry i� j nonzero� where AG is the incidence matrix of G�
Remark� In connection with algorithms for fast matrix multiplication�this observation gives the fastest known method for deciding whethera given graph contains a triangle� substantially faster than the obviousOn� algorithm�
��� Graphs� an introduction
��� �Let G be a graph� Prove the following formula for the number ofcycles of length � in G not necessarily induced�
�
�
�trace
�A�G
�� �jEGj � � XvV �G�
�degGv
�
���
Here A�G is the �th power of the incidence matrix� and trace
�A�G
�denotes the sum of the elements on the main diagonal of A�
G� For thede�nition of degGv� see the next section� Note that this gives anOn� algorithm for counting the number of cycles of length �� or evena faster algorithm using algorithms for fast matrix multiplication�
��� Prove that G andG� are isomorphic if and only if a permutation matrixP exists such that
AG� � PAGPT �
Here AG is the adjacency matrix of G and PT denotes the transposed
matrix P � A matrix P is called a permutation matrix if its entries are and � and each row and each column contain precisely one ��
��� Graph score
Let G be a graph� and let v be a vertex of G� The number of edgesof G containing the vertex v is denoted by the symbol degG�v� Thenumber degG�v is called the degree of v in the graph G�
Let us denote the vertices of G by v�� v�� � � � � vn �in some arbi�trarily chosen order� The sequence
�degG�v��degG�v�� � � � �degG�vn
is called a degree sequence of the graphG� or a score ofG� By choosingdi�erent numberings of the vertices of the same graph� we usuallyobtain several di�erent sequences of numbers di�ering by the orderof their terms� Thus� we will not distinguish two scores if one ofthem can be obtained from the other by rearranging the order of thenumbers� We will usually write scores in nondecreasing order� withthe smallest degree coming �rst�
It is easy to see that two isomorphic graphs have the same scores�and thus two graphs with di�erent scores are necessarily noniso�morphic� On the other hand� graphs with the same score need notbe isomorphic� For example� the graphs
��� Graph score ���
Fig� ��� Three connected nonisomorphic graphs with the same score�
both have score ��� �� �� �� �� �� but they cannot be isomorphic sinceone of them is connected while the other one is not� All the threegraphs in Fig� ��� have score ��� �� �� �� �� �� �� �� �� � but no two ofthem are isomorphic �to prove this is a bit harder� see Exercise ��In spite of these negative examples� the score is an important andeasily computable characteristic of a graph� and it can often help todistinguish nonisomorphic graphs in practice�
A problem studied in graph theory� although not really one ofthe most important ones� is to characterize sequences of numbersthat can appear as scores of graphs� One such basic and often quitesigni�cant property is a consequence of the following observation�
����� Proposition� For each graph G � �V�E we haveXv�V
degG�v � �jEj�
Proof� The degree of a vertex v is the number of edges containing v�Each edge contains � vertices� and hence by summing up all degreeswe get twice the number of edges� �
����� Corollary �Handshake lemma�� The number of odd�de�
gree vertices is even� in any graph� �Or� the number of participants
at a birthday party who shook hands with an odd number of other
participants is always even for any �nite party��
Let us remark that the handshake lemma is not true for in�niteparties� A one�sided in�nite path has a single odd�degree vertex�
� � �
The handshake lemma �Corollary ������ and some other simplenecessary conditions� are not su�cient to characterize sequences thatcan show up as graph scores �see Exercise �� A full characterization
��� Graphs� an introduction
of scores is not quite simple� and it is related to so�called network ows which are not treated in this book� Here we explain a simplealgorithm for deciding whether a given sequence of integers is a graphscore or not� The algorithm is an easy consequence of the followingresult�
����� Theorem �Score theorem�� Let D � �d�� d�� � � � � dn be asequence of natural numbers� n � �� Suppose that d� � d� � � � � �dn� and let the symbol D� denote the sequence �d��� � � � � d
�n��� where
d�i �
�di for i � n� dndi � � for i � n� dn�
For example� for D � ��� �� �� �� �� �� �� we have D� � ��� �� �� �� �� ��Then D is a graph score if and only if D� is a graph score�
Proof� One implication is easy� Suppose that D� is a score of agraphG� � �V �� E�� where V � � fv�� v�� � � � � vn��g and degG�vi � d�ifor all i � �� �� � � � � n � �� Fix a new vertex vn distinct from all ofv�� � � � � vn��� and de�ne a new graph G � �V�E where
V � V � � fvngE � E� � ffvi� vng� i � n� dn� n� dn % �� � � � � n� �g�
Expressed less formally� the new vertex vn is connected to the dnlast vertices of the graph G�� Clearly G has score D� �Rememberingthis construction is the best way to remember the statement of thetheorem�
It is more di�cult to prove the reverse implication� i�e� if D is ascore then D� is a score� So assume that D is a score of some graph�The trouble is that in general� we cannot reverse the constructionby which we passed from D� to D� i�e� to tear o� a largest�degreevertex� since such a vertex can be connected to other vertices thanwe would need� An example is shown in the following picture�
v� v�v� v� v� v
v
We thus consider the set G of all graphs on the vertex setfv�� � � � � vng in which the degree of each vertex vi equals di� i ��� �� � � � � n� We prove the following�
��� Graph score ���
v� v�� � � � � � � � �� � �
vk vi vj vn
the last vertex not connected to vn
Fig� ��� Illustration for the proof of the score theorem�
Claim� The set G contains a graph G� in which the vertex vn isadjacent exactly to the vertices vn�dn � vn�dn�� � � � � vn��� i�e� to thelast dn vertices�
Having a graph G� as in the claim� it is already clear that thegraph G� � �fv�� � � � � vn��g� E�� where E� � fe � E�G�� vn � eg�has score D� �i�e� we can remove the vertex vn in G�� and this provesthe score theorem� It remains to establish the claim�
If dn � n � �� i�e� vn is connected to all other vertices� thenany graph from G satis�es the claim� So suppose dn � n � � andde�ne� for a graph G � G� a number j�G as the largest index j �f�� �� � � � � n� �g such that fvj � vng � E�G� Let G� � G be a graphwith the smallest possible value of j�G� We prove that j�G� �n � dn � �� and from this one can already see that G� satis�es theclaim�
For contradiction� let us suppose that j � j�G� � n�dn��� Thevertex vn has to be adjacent to dn vertices� and at most dn�� of themcan have a larger index than vj� Hence there exists some index i � jsuch that vi is adjacent to vn� and so we have fvj � vng � E�G��fvi� vng � E�G� �refer to Fig� ���� Since degG�
�vi � degG��vj�
there exists a vertex vk adjacent to vj but not to vi� In this situation�we consider a new graph G� � �V�E�� where
E� � �E�G� n ffvi� vng� fvj � vkgg � ffvj � vng� fvi� vkgg�It is easy to check that the graph G� has score D too� and at thesame time j�G� � j�G� � �� which contradicts the choice of G��This proves the claim� and hence also Theorem ����� is proved� �
As we have said� the theorem just proved gives an easy methodfor deciding whether a given sequence is a graph score� We illustratethe procedure with a concrete example�
��� Graphs� an introduction
Problem� Decide whether there exists a graph with score ��� �� ���� �� �� �� �� ��
Solution� We reduce the given sequence by a repeated use of thescore theorem ������
��� �� �� �� �� �� �� �� ���� �� �� �� �� �� �� ���� �� �� �� �� �� �� rearranged nondecreasingly ��� �� �� �� �� �� ���� �� �� �� �� �� rearranged ��� �� �� �� �� ���� �� �� ��Since the last sequence is a graph score �of the graph with �
vertices and no edges� we get that the original sequence is a scoreof some graph as well� Construct an example of such a graph�
Exercises
�� Prove that the three graphs in Fig� ��� are pairwise nonisomorphic�
�� Construct an example of a sequence of length n in which each term issome of the numbers �� �� � � � � n� � and which has an even number ofodd terms� and yet the sequence is not a graph score�
�� Where was the assumption d� � d� � � � � � dn used in the proof ofthe score theorem� Show that the statement is not true if we omit thisassumption�
�� Find a smallest possible example with the smallest number of verticesof two connected nonisomorphic graphs with the same score�
�� Draw all nonisomorphic graphs with score �� �� �� �� �� �� �� Prove thatnone was left out�
�� Find an example� as small as possible� of a graph with � vertices ofdegree �� other vertices of degree � �� and with �� edges�
�� Let G be a graph with � vertices� each of degree � or �� Prove that ithas at least � vertices of degree � or at least � vertices of degree ��
�� a Decide for which n � there exists a graph whose score consistsof n distinct numbers�
b �For which n does there exist a graph on n vertices whose score hasn� � distinct numbers i�e� exactly � vertices have the same degree�
�� Let G be a graph in which all vertices have degree at least d� Provethat G contains a path of length d not necessarily an induced one�
� � �Let G be a graph with maximum degree �� Prove that its vertices canbe colored by � colors each vertex gets one color in such a way thatthere is no path of length � whose � vertices all have the same color�
��� Eulerian graphs ���
��� ��Let G be a graph with all vertices of degree at least �� Show thatthen G contains a cycle which is not induced i�e� it has a �diagonal��
��� A graph G is called k�regular if all its vertices have degree exactly k�Determine all pairs k� n such that there exists a k�regular graph onn vertices�
��� Draw all nonisomorphic ��regular graphs on � vertices�
��� Find a ��regular asymmetric graph see Exercise ������
��� a Show that the following graph and the graph in Fig� ��� are iso�morphic�
b �Prove that any ��regular graph with �� vertices containing nocycle of length � or smaller is isomorphic to the graph in a thisgraph is called the Heawood graph� Reading Chapter � �rst mighthelp�
��� �Let G be a connected graph in which any two distinct vertices u� vhave either or � common neighbors� Prove that G is k�regular forsome k�
��� ��Prove that each graph with an even number of vertices has twovertices with an even number of common neighbors�
��� Eulerian graphs
Here is one of the oldest problems concerning graph drawing�
Problem� Draw a given graph G � �V�E with a single closedline� without lifting the pencil from the paper �and drawing eachedge only once�
Mathematically� this can be formalized as follows� �nd a closedwalk �v�� e�� v�� � � � � em��� vm��� em� v� containing all the vertices andall the edges� each edge exactly once �while vertices can be repeated��Note that the �rst vertex and the last vertex coincide� Such a walkis called a closed Eulerian tour in G� and a graph possessing a closedEulerian tour is called Eulerian�
��� Graphs� an introduction
Here is an example of drawing a graph with a single line�
�
and here is another one�
a handmade �gure comes here
It turns out that Eulerian graphs can be characterized nicely bya �local� condition� using vertex degrees�
����� Theorem �Characterization of Eulerian graphs�� A
graph G � �V�E is Eulerian if and only if it is connected and eachvertex has an even degree�
Proof� It is rather easy to show that the condition is necessary forG to be Eulerian� Clearly� an Eulerian graph must be connected� Thereason for each degree being even is that whenever a closed Euleriantour enters a vertex it must also leave it� In more detail� if we �xsome direction of traversing the closed Eulerian tour and considersome vertex v � V �G� the edges incident to v can be classi�ed aseither ingoing or outgoing� and the tour de�nes a bijection betweenthe set of the ingoing edges and the set of the outgoing edges�
Proving that a connected graph with all degrees even has a closedEulerian tour is a bit more demanding� For brevity� de�ne a tour inG as a walk in which no edge is repeated �vertices can be repeated�though� Consider a tour T � �v�� e�� v�� � � � � em� vm in G of thelargest possible length� m� We prove that
�i v� � vm� and
�ii fei� i � �� �� � � � �mg � E�
��� Eulerian graphs ���
Ad �i�� If v� � vm then the vertex v� is incident to an odd numberof edges of the tour T � But since the degree degG�v� is even� thereexists an edge e � E�G not contained in T � Hence we could extendT by this edgea contradiction�
Ad �ii�� So� assume that v� � vm� Write V �T for the set of verticesoccurring in T and E�T for the set of edges in T � First assumeV �T � V � Thanks to the connectedness of G� an edge exists of theform e � fvk� v�g � E�G� where vk � V �T and v� � V �T � In thiscase� the tour
�v�� e� vk� ek�� vk�� � � � � vm��� v�� e�� v�� � � � � ek� vk
has length m% � and thus leads to a contradiction� Pictorially�
vk
v�T
�
vk
v�
If V �T � V and E�T � E� consider an edge e � E nE�T � andwrite e � fvk� v�g� Analogously to the previous case� a new tour
�vk� ek�� vk�� � � � � vm��� em� v�� e�� v�� � � � � ek� vk� e� v�
leads to a contradiction� Pictorially�
vk
v��
vk
v�
This proves Theorem ������ �
Note that the main trick in the proof is to look at the longest
possible tour� the rest is more or less routine� This trick is worthremembering� since similar twists occur in numerous graph theoryproofs �in this book see e�g� Exercise ������ or Lemma ������
Remark about multiple edges� So far we have de�ned an edge ofa graph as a ��point set of vertices� and we will stick to this de�nitionin most of the rest of this book� This means� among other things�that two vertices can be connected by at most one edge� In someapplications� it is natural to admit two vertices to be connected by
�� Graphs� an introduction
several distinct edges� We thus get graphs with multiple edges� alsocalled multigraphs� Mathematically� this notion can be formalized inseveral di�erent ways� some of them being more handy than others�
For instance� we could assign a nonnegative integer mu� v to eachpair fu� vg of vertices� This mu� v would be the multiplicity of the edgefu� vg� Hence mu� v � would mean that the edge is not present inthe graph� mu� v � � would denote an �ordinary� simple edge� andmu� v � � would say that the graph contains mu� v �copies� of theedge fu� vg� A multigraph would then be an ordered pair V�m� wherem�
�V�
�� f � �� �� � � �g�Another common way of introducing multiple edges� a more ele�
gant one from a certain point of view� is to consider edges as �ab�stract� objects� i�e� to take E as some �nite set disjoint from thevertex set V � For each edge e � E� we then determine the pair ofend�vertices of e� The same pair of vertices can occur for severaledges� Formally� a graph with multiple edges is an ordered triple�V�E� �� where V and E are disjoint sets and ��E � �V
�
�is a map�
ping determining the end�vertices of edges� Imagine that we have agraph�building kit with a supply of vertices and edges� then the map�ping � tells us how to assemble a particular graph from the verticesand edges�
Sometimes it is useful also to admit loops in a graph� i�e� edgesbeginning and ending in the same vertex� Formally� loops can againbe introduced in a number of ways� The simplest way is to representa loop attached to a vertex v as the ��element set fvg in the edgeset E �while the ordinary edges are ��element sets� If multiple edgesare introduced using the mapping �� loops can be added by letting� be a mapping into the set
�V�
�� V � and a loop e is mapped by � to
��� Eulerian graphs ���
its single end�vertex�Yet another modi�cation of the notion of a graph� the so�called
directed graphs� will be discussed in Section ����For simple applications� the formal way of introducing multiple
edges and loops doesn�t really matter a great deal� provided that wechoose a single way and keep to it consistently� and if this chosenway is not too clumsy�
Exercises
�� The following sketch of a city plan depicts � bridges�
a Show that one cannot start walking from some place� cross eachof the bridges exactly once� and come back to the starting place noswimming please� Can one cross each bridge exactly once if it is notrequired to return to the starting position�
This is a historical motivation for the notion of the Eulerian graphs�The scheme loosely corresponds to a part of the city of K&onigsberg�Kr'alovec� Kr'olewiec� or Kaliningrad�that�s what it was variously calledduring its colorful history�and the problem was solved by Euler in����� Can you �nd the city on a modern map�
b How many bridges need to be added and where so that a closedtour exists�
Remark� Many people� not armed with the notion of a graph� mighttry to solve the K&onigsberg bridges practically� by actually walkingthrough the city� If you have ever tried to �nd your way in a foreigncity� you will probably agree that the chance of �nding the negativesolution in this way is negligible� From this point of view� one canappreciate Euler�s genius and the simplicity of the graph model of thesituation�
�� Characterize graphs that have a tour� not necessarily a closed one�covering all edges�
��� Graphs� an introduction
�� Draw the following graphs with a single line�
�� a Formulate an algorithm for �nding a closed Eulerian tour in a givengraph� based on the above proof of Theorem ������
b CS How fast can you implement it i�e� how many steps are neededfor a graph with n vertices and m edges in the worst case�
�� Give an alternative proof of Theorem ������ based on the followingoutline�
a Prove that if a graph G has all degrees even� its edge set can beexpressed as a disjoint union of edge sets of cycles in G�
b Show that two edge�disjoint closed tours with at least one vertexin common can be combined into a single closed tour� Prove Theo�rem ����� using a and b�
�� Check that Theorem ����� also holds for graphs with loops and multipleedges what is the correct way to de�ne the degree of a vertex for suchgraphs��
�� Characterize the sequences of nonnegative integers that can appearas scores of graphs possibly with loops and multiple edges� A loopincreases the vertex degree by ��
�� A Hamiltonian cycle in a graphG is a cycle containing all vertices of G�This notion may seem quite similar to an Eulerian tour but it turns outthat it is much more di�cult to handle� For instance� no e�cient algo�rithm is known for deciding whether a graph has a Hamiltonian cycleor not� This and the next two exercises are a microscopic introductionto this notion another nice result is mentioned in Exercise ������
a Decide which of the graphs drawn in Fig� ��� has a Hamiltoniancycle� Try to prove your claims�
b Construct two connected graphs with the same score� one with andone without a Hamiltonian cycle�
�� For a graph G� let LG denote the so�called line graph of G� givenby LG � E�
�fe� e�g� e� e� � EG� e� e� �� �� Decide whether thefollowing is true for every graph G�
a G is connected if and only if LG is connected�
b G is Eulerian if and only if LG has a Hamiltonian cycle seeExercise � for a de�nition�
�� An algorithm for an Eulerian tour ���
� � a �Prove that every graph G with n vertices and with all verticeshaving degree at least n
� has a Hamiltonian cycle see Exercise � for ade�nition�
b �Is it su�cient to assume degrees at least bn��c in a�
��� An algorithm for an Eulerian tour
Theorem ����� provides a very simple method for showing the nonex�istence of an Eulerian tour in a connected graph� �nd an odd�degreevertex� If all degrees are even� the proof given in the preceding sec�tion actually allows us to construct an Eulerian tour� i�e� to drawa graph with a single line� start with an arbitrary tour and keepextending it� In this section we give another proof of the theorem�formulated directly as an algorithm for �nding a suitable way ofdrawing� This algorithm is more suitable for �manual� use� havingalready drawn some edges� the algorithm tells us how to continue�A more detailed analysis� which we do not include here� also showsthat the new algorithm is faster� provided that all operations areimplemented cleverly�
We need some preparation� Let G � �V�E be a graph� Callan edge e � E a bridge� of G if the graph �V�E n feg has morecomponents than G� This de�nition has a quite intuitive meaning�
bridgenot a bridge
����� Lemma� If all vertex degrees in a graph G are even then Ghas no bridge�
Proof� We may assume that G is connected� for otherwise thelemma could be applied to each component separately� For contra�diction� suppose that an edge fv�� v�g � e is a bridge of G� The graph�V�Enfeg has exactly � components� Let G� be the component con�taining v�� All vertices of G� have an even degree except for v� whosedegree in G� is odd� But this is impossible by the handshake lemma�Corollary ������ �
�Another common term� more appropriate for a sailor�s mentality� is isthmus�
��� Graphs� an introduction
����� Algorithm �How to draw a graph with a single line��
The algorithm can be summarized as follows� keep drawing and neveruse an edge whose deletion creates a new component if this can beavoided� A detailed description follows�
Let G � �V�E be a connected graph with all vertex degrees even�and put jEj � m�
Step �� Choose v� � V arbitrarily� Set T� � �v��
Step �� Repeat step � below for i � �� �� �� � � � � until it is no longerpossible� If step � cannot be executed anymore� then i � m andTm is the required Eulerian tour�
Step �� �Extending the tour Let Ti � �v�� e�� v�� � � � � ei� vi be thetour constructed so far� Choose an edge ei� � Enfe�� e�� � � � � eigcontaining the vertex vi� Moreover� whenever possible� chooseei� in such a way that the graphs �V�E n fe�� � � � � eig and�V�E n fe�� � � � � ei� ei�g have the same number of components�
Proof of correctness of the algorithm� Let Tk � �v�� e�� v�� � � � �ek� vk be the result of the computation of the algorithm� For i ��� �� � � � � k� let the symbol Gi denote the graph G after edges e�through ei have been removed� Clearly degGk
�vk � �� for otherwisewe could extend the tour in step �� and hence v� � vk�
For contradiction� suppose that the tour Tk does not pass throughall the edges ofG� i�e� that E�Gk � �� and letW be the set of verticeswhose degree in Gk is nonzero�
Since G is a connected graph� the tour Tk visits the �nonemptyset W at least once� Let vt be the vertex in which the tour Tk visitsW for the last time� This means that t is the maximum index withvt � W � Since vk � W � we have vt� � W � Because Gk�s edges alllive on the set W and the edge et� is the last edge of the tourTk incident to W � the edge et� is the only edge of the graph Gt
joining a vertex of W to a vertex outside W � In other words� et� isa bridge in the graph Gt and Gt� has more components than Gt�The following �gure illustrates the situation in the graph Gt�
vtet�
vt�e V nWW
G�
�� An algorithm for an Eulerian tour ���
Let e be an edge of Gt containing the vertex vt and di�erent fromet� �such an edge exists since degGt��
�vt � degGk�vt � �� By the
rule in step �� this e must also be a bridge in Gt� otherwise we wouldhave selected it instead of et�� The other endpoint of e also lies inW �no edge in Gt leaves W except for et�� and so e is even a bridgein G� � �W�E�Gt
�W�
�� the subgraph induced by the set W in the
graph Gt�At the same time� the subgraph induced by W doesn�t change
by removing the subsequent edges of the tour Tk� Written in sym�bols� E�G� � E�Gk
�W�
�� E�Gk� The degrees of all vertices in
the graph Gk� and thus also in G�� are even� and this contradictsLemma ����� applied to G�� �
Example� This graph G
can be drawn with a single line like this
or like this
but not like this
��� Graphs� an introduction
wrong step
Exercises
�� CS Design the details of the algorithm described above for �nding anEulerian tour the main problem is how to check the condition in step �e�ciently� Try to estimate the number of steps of the algorithm for agraph with n vertices and m edges in the worst case�
�� We say that a graph G � V�E is randomly Eulerian from a vertex v�if every maximal tour starting at v� is already a closed Eulerian tourin G� That is� if we start at v� and draw edges one by one� choosinga continuation arbitrarily among the yet unused edges� we can neverget stuck� It would be nice if art galleries or zoos were randomlyEulerian� but unfortunately they seldom are� The result in part cbelow indicates why�
a Prove that the following graphs are randomly Eulerian�
v�v�
b Show that the graphs below are not randomly Eulerian�
v�
v�
��� Eulerian directed graphs ���
c �Prove the following characterization of randomly Eulerian graphs�A connected graph G � V�E all of whose vertices have even de�gree is randomly Eulerian from a vertex v� if and only if the graphV n fv�g� fe � E� v� �� eg contains no cycle�
�� Let G be a bipartite k�regular graph for some k �� Prove that G hasno bridge�
��� Eulerian directed graphs
All graphs considered so far were �undirected�their edges wereunordered pairs of vertices� Many situations involve one�way streetsand schemes similar to the following�
To re ect such situations� one introduces directed graphs� where ev�ery edge has a direction�
����� De�nition� A directed graph G is a pair �V�E� where E is a
subset of the Cartesian product V V � The ordered pairs �x� y � Eare called directed edges� We say that a directed edge e � �x� y hashead y and tail x� or� that e is an edge from x to y�
Further we could introduce directed graphs with multiple edges�and also for each notion or problem for undirected graphs� we couldlook at its directed analogy� Sometimes the results for directed graphsare simple modi�cations of the results for undirected graphs� In someother problems� the directed and undirected cases di�er substan�tially� and as a rule� the directed version is then more di�cult tohandle� In this book� we deal almost exclusively with undirectedgraphs� Let us make an exception here and introduce Eulerian di�rected graphs and describe one of their cute applications�
An attentive reader might have noticed that a directed graph G �V�E is the same object as a relation on the set V � Nevertheless� both
�Here is some alternative terminology� The arti�cial word digraph is often usedfor a directed graph� A directed edge is sometimes called an arrow� a �directed�arc� etc� An oriented graph is a special type of a directed graph� where we do notadmit directed edges �x� y� and �y� x� simultaneously�
��� Graphs� an introduction
these notions are introduced� since directed graphs are investigated indi�erent contexts than relations�
It is quite natural to de�ne a directed tour in a directed graphG � �V�E as a sequence
�v�� e�� v�� e�� � � � � em� vm
such that ei � �vi��� vi � E for each i � �� �� � � � �m and� moreover�ei � ej whenever i � j� Similarly we can de�ne a directed walk�directed path� and directed cycle�
We say that a directed graph �V�E is Eulerian if it has a closeddirected tour containing all vertices and passing each directed edgeexactly once� Eulerian directed graphs can again be characterizednicely� Before stating the theorem� we should add a few more notions�
For a given vertex v in a directed graph G � �V�E� let us denotethe number of directed edges ending in v �i�e� having v as the headby degG�v� Similarly� deg�G�v stands for the number of directededges originating in v� The number degG�v is called the indegree ofv� and deg�G�v is the outdegree of v�
Each directed graph G � �V�E can be assigned an undirectedgraph sym�G � �V� +E� where
+E � ffx� yg� �x� y � E or �y� x � Eg�
The graph sym�G is called the symmetrization of the graph G�Now we can formulate the promised characterization of Eulerian
directed graphs�
����� Proposition� A directed graph is Eulerian if and only if its
symmetrization is connected� and degG�v � deg�G�v holds for eachvertex v � V �G�
A proof of this proposition is very similar to the proof of Theo�rem ������ and we leave it as an exercise�
�A directed cycle is sometimes simply called a cycle in the literature� or theneologism dicycle is also occasionally used� which may sound more like a namefor some obscure vehicle�
A directed graph whose symmetrization is connected is called weakly connec�
ted �a policeman who can ignore one�way street signs can get from any vertex toany other one�� On the other hand� in a strongly connected directed graph� anytwo vertices can be connected by a directed path� in both directions�
��� Eulerian directed graphs ���
An application� A wheel has a sequence of n digits � and � writtenalong its circumference� We can read k consecutive digits through aslot�
The sequence of n digits should be such that the position of the wheelcan always be detected unambiguously from the k digits in the slot�no matter how the wheel is rotated� �Imagine a device for controllingthe angular position of a radar or something else your fantasy canenvisage� For a given k� we want to manufacture a wheel with nas large as possible �so that the angular position can be controlledfairly precisely� A mathematical formulation of the problem is thefollowing�
Problem� Find a cyclic sequence of digits � and �� as long as pos�sible� such that no two k�tuples of consecutive digits coincide �herea cyclic sequence means positioning the digits on the circumferenceof a circle�
Let ��k denote the maximum possible number of digits in sucha sequence for a given k� We prove the following surprising result�
Proposition� For each k � � we have ��k � �k�
Proof� Since the number of distinct k�digit sequences made of digits� and � is �k� the length of the cyclic sequence cannot be longer than�k� It remains to construct a cyclic sequence of length �k with therequired property� The case k � � is easy� so let us assume k � ��
De�ne a graph G � �V�E in the following manner�
� V is the set of all sequences of �s and �s of length k � � �sojV j � �k���
� The directed edges are all pairs of �k� ��digit sequences of theform
��a�� � � � � ak��� �a�� � � � � ak�
Directed edges are in a bijective correspondence with k�digit se�quences
�� Graphs� an introduction
�
�
�
��
��
� �
���
��
� �
�� �
� �
Fig� ��� The directed graph in the wheel problem�
�a�� a�� � � � � ak�
and hence jEj � �k� For brevity� let us denote the directed edge��a�� � � � � ak��� �a�� � � � � ak by �a�� a�� � � � � ak� No confusion shouldarise�
The reader will probably agree that deg�G�v � degG�v � � foreach vertex v � V � The symmetrization of G is connected� becauseby repeatedly omitting the last term of a �k� ��digit sequence andadding �s to its beginning we can convert any sequence to the se�quence of �s� Hence G is an Eulerian directed graph� Examples fork � � and k � � are shown in Fig� ����
Set jEj � �k � K� and let �e�� � � � � eK be the sequence of edgesin some directed Eulerian tour in G� Each edge ei has the formei � �ai�� � � � � a
ik� The desired cyclic sequence of digits � and � of
lengthK for our wheel can be de�ned as �a��� a��� � � �� a
K� � That is� we
take the �rst element from each ei� Each subsequence of k consecutivedigits in this sequence corresponds to traversing one directed edgeof the Eulerian tour� and since no directed edge is repeated in thetour� no two k�digit segments coincide� This proves ��k � �k�
For example� for k � �� from the graph in Fig ��� we can �nd atour ��� ��� ��� �� and the corresponding cyclic sequence ����� andfor k � � we get a tour ���� ���� ���� ���� ���� ���� ���� ��� andthe corresponding cyclic sequence ��������� �
Let us remark that the noteworthy graphs constructed in the pre�ceding proof are called the De Bruijn graphs� Although they are ex�ponentially large in k� the neighbors of a given vertex can be foundquickly� They are sometimes used as interconnecting networks in parallelcomputing� Other graphs with similar properties are the k�dimensional
��� Eulerian directed graphs ���
cubes� the vertex set is again all sequences of s and �s of length k�and two sequences are adjacent if and only if they di�er in exactly onecoordinate�
Exercises
�� Prove Proposition ������
�� Design an algorithm for �nding an Eulerian directed tour in a directedgraph�
�� When can a directed graph be drawn with a single line not necessarilya closed one� Each directed edge must be drawn exactly once and inthe direction from its tail to its head�
�� Let G � V�E be a graph� An orientation of G is any oriented graphG� � V�E� arising by replacing each edge fu� vg � E either by thedirected edge u� v or by the directed edge v� u�
a Prove that if all degrees of G are even then an orientation H of Gexists with deg�Hv � deg
�Hv for all vertices v � V G�
b Prove that a directed graph G satisfying deg�Gv � deg�Gv for all
vertices v is strongly connected if and only if it is weakly connected�
�� �Let G � V�E be a directed graph� and let w�E � R be a functionassigning a real number to each edge� A function p�V � R de�ned onvertices is called a potential for w if we � pv� pu holds for everydirected edge e � u� v� Prove that a potential for w exists if and onlyif the sum of the values of w over the edges of any directed cycle in Gis �
�� �Prove that the following two conditions for a strongly connected di�rected graph G are equivalent�
i G contains a directed cycle of an even length�
ii The vertices of G can be colored by � colors each vertex receivesone color in such a way that for each vertex u there exists a directededge u� v with v having the color di�erent from the color of u�
�� ��Knights from two enemy castles are sitting at a round table andnegotiating for peace� The number of knights with an enemy sittingon their right�hand side is the same as the number of knights with anally on their right�hand side� Prove that the total number of knightsis divisible by ��
�� �A tournament is a directed graph such that for any two distinct ver�tices u� v� exactly one of the directed edges u� v and v� u is presentin the graph� Prove that each tournament has a directed path passingthrough all vertices such a path is called Hamiltonian�
��� Graphs� an introduction
�� �Prove that in any tournament see Exercise � for a de�nition� thereexists a vertex v that can be reached from any other vertex by adirected path of length at most ��
��� ��connectivityA graph G is called k�vertex�connected if it has at least k � � verticesand it remains connected after removing any k�� vertices� A graph G iscalled k�edge�connected if we obtain a connected graph by deleting anyk� � edges of G� The maximum k such that G is k�vertex�connected iscalled the vertex connectivity of G� and similarly for edge connectivity�If a graph is a scheme of a city public transport network� a railway
network� telephone cables� etc�� its higher connectivity gives hope for areasonable functioning of the network even in critical conditions� whenone or several nodes or connections of the network fail� The notions ofvertex connectivity and edge connectivity are theoretically and prac�tically quite important in graph theory� They are related to so�callednetwork �ows� which are not treated in this book� Here we restrict ourattention to ��vertex�connectivity� which will be needed in a chapteron planar graphs� and which will also serve as an illustration for someproof methods and constructions�
Instead of vertex ��vertex�connectivity we will brie y say ��connec�tivity� To be on the safe side� let us give the de�nition once more�
���� De�nition ��connectivity�� A graph G is called ��connec�ted if it has at least � vertices� and by deleting any single vertex we
obtain a connected graph�
It is easy to check that a ��connected graph is also connected�here we need the assumption that a ��connected graph has at least� verticeswe recommend the reader to think this over� In thissection we give alternative descriptions of ��connected graphs� Beforewe begin with this� we introduce the notation for several graph�theoretic operations� It simpli�es formulas considerably and will alsobe useful later on�
���� De�nition �Some graph operations�� Let G � �V�E bea graph� We de�ne various new graphs created from G�
� �Edge deletion�
G� e � �V�E n feg�
where e � E is an edge of G�
��� �connectivity ���
e
G
e�
v
G� e G� v G%eG� e�
Fig� ��� Examples of graph operations�
� �Adding a new edge�
G% +e � �V�E � f+eg�where +e � �V
�
� n E is a pair of vertices that is not an edge of G�
� �Vertex deletion�
G� v � �V n fvg� fe � E� v � eg�where v � V �we delete the vertex v and all edges having v as
an endpoint��
� �Edge subdivision�
G,e �
�V � fzg� �E n ffx� ygg � ffx� zg� fz� ygg
��
where e � fx� yg � E is an edge� and z � V is a new vertex �we
draw a new vertex z on the edge fx� yg��We say that a graph G� is a subdivision of the graph G if G� is
isomorphic to a graph created from G by successive operations of
edge subdivision�
Examples of the operations just de�ned are shown in Fig� ����Let us go back to ��connectivity� Here is the �rst remarkable
equivalent characterization�
���� Theorem� A graph G is ��connected if and only if there ex�
ists� for any two vertices of G� a cycle in G containing these two
vertices�
��� Graphs� an introduction
Let us remark that this theorem is a particular case of a very im�portant result called Menger�s theorem� which says the following� If xand y are two vertices in a k�vertex�connected graph� then there existk paths from x to y that are mutually disjoint except for sharing thevertices x and y�
Proof� The given condition is� no doubt� su�cient� since if twovertices v� v� lie on a common cycle then there exist two paths con�necting them having no common vertices except for the end�vertices�and so v and v� can never fall into distinct components by removinga single vertex�
We now prove the reverse implication� The existence of a com�mon cycle for v� v� will be established by induction on dG�v� v
�� thedistance of the vertices v and v��
First let dG�v� v� � �� This means that fv� v�g � e � E�G�
By ��connectivity of G� the graph G � e is connected �if it weredisconnected� at least one of the graphs G� v� G� v� would also bedisconnected� Therefore there exists a path from v to v� in the graphG�e� and this path together with the edge e forms the required cyclecontaining both v and v��
Next� suppose that any pair of vertices at distance less than k lieson a common cycle� for some k � �� Consider two vertices v� v� � Vat distance k� Let P � �v � v�� e�� v�� � � � � ek� vk � v� be a shortestpath from v to v�� Since dG�v� vk�� � k��� a cycle exists containingboth v and vk��� This cycle consists of two paths� P� and P�� fromv to vk��� Now consider the graph G � vk��� It is connected� andhence it has a path P from v to v�� This path thus doesn�t containvk��� Let us look at the last vertex on the path P �when going fromv to v� belonging to one of the paths P�� P�� and denote this vertexby w� as in the illustration�
v
vk��
v�
wP�
P�(P
Without loss of generality� suppose that w is a vertex of P�� Thenthe desired cycle containing v and v� is formed by the path P�� bythe portion of the path P� between v and w� and by the portion of
��� �connectivity ���
the path P between w and v� �drawn by a thick line� �
���� Observation� A graph G is ��connected if and only if any
subdivision of G is ��connected�
Proof� It is enough to show that� for any edge e � E�G� G is��connected if and only if G,e is ��connected� If v � V �G is avertex of G� it is easy to see that G � v is connected if and only if�G,e�v is connected� Therefore� ifG,e is ��connected then so isG�For the reverse implication� it remains to show that for a ��connectedG� the graph �G,e � z is connected� where z is the newly addedvertex� This follows from the fact �observed in the previous proofthat G� e is connected for a ��connected G� �
The next characterization of ��connected graphs is particularlysuitable for proofs� We show how ��connected graphs are built fromsimpler graphs�
���� Theorem ��connected graph synthesis�� A graph G is
��connected if and only if it can be created from a triangle �i�e� fromK�� by a sequence of edge subdivisions and edge additions�
Such a synthesis is illustrated below�
G
% % �
%
��
Proof� Every graph that can be produced from K� by the above�mentioned operations is obviously ��connected� So� we need to provethat we can construct each ��connected graph�
��� Graphs� an introduction
Actually� we show the possibility of creating any ��connectedgraph by a somewhat di�erent construction� We start with a cy�cle G�� and if a graph Gi�� has already been built� a graph Gi arisesby adding a path Pi connecting two vertices of the graph Gi��� Thepath Pi only shares its end�vertices with Gi��� while all edges andall inner vertices are new� As illustrated in the following drawing�
G�
P�
P�
P�
we successively glue �ears� to the graph G �and� indeed� the decom�position is commonly called an ear decomposition�
Since adding a path can be simulated by an edge addition andedge subdivisions�� it su�ces to show that every ��connected graphG can be produced by a repeated ear addition�
Let us pick a cycle G� in the graph G arbitrarily� Suppose thatgraphs Gj � �Ej � Vj for j � i have already been de�ned� withproperties as described above� If Gi � G the proof is over� so let usassume that Ei � E�G� Since G is connected� there exists an edgee � E�G n Ei such that e Vi � ��
If both vertices of e lie in Vi then we put Gi� � Gi % e� In theother case� let e � fv� v�g� where v � Vi� v
� � Vi�
v
v�
v��G� G�
Consider the graph G�v� This is connected �since G is ��connected�and therefore a path P exists connecting the vertex v� to some vertexv�� � Vi� where v
�� is the only vertex of the path P belonging to Vi �to
�One has to be careful here� if v� v� � V �Gi��� are already connected by anedge and if we want to connect them by a new path� we cannot start by addingthe edge fv� v�g �at least if we do not allow multiple edges�� We have to subdividethe edge fv� v�g �rst� then again add the edge fv� v�g� and then continue extendingthe path by subdivisions if needed�
��� �connectivity ���
this end� take the shortest path joining v� to Vi in the graph G� v�Then we can de�ne the graph Gi� by adding the edge e and thepath P to Gi� i�e� Vi� � Vi � V �P � Ei� � Ei � feg �E�P � �
Exercises
�� Prove that for any two edges of a ��connected graph� a cycle existscontaining both of them�
�� Let G be a critical ��connected graph� this means that G is ��connectedbut no graph G� e for e � EG is ��connected�
a Prove that at least one vertex of G has degree ��
b For each n� �nd an example of a critical ��connected graph with avertex of degree at least n�
c �For each n� give an example of a critical ��connected graph with avertex of degree n� which is at distance at least n from each vertexof degree ��
�� a Is it true that any critical ��connected graph see Exercise � can beobtained from a cycle by successive gluing of �ears� paths of lengthat least ��
b Is it true that any critical ��connected graph can be obtained froma cycle by a successive gluing of �ears� in such a way that each of theintermediate graphs created along the way is also critical ��connected�
�� Prove that any ��connected graph has a strongly connected orientationsee Section ��� for these notions�
�� �Determine the vertex connectivity of the k�dimensional cube� Thek�dimensional cube was de�ned at the end of Section ����
�� �Let d � be an integer� and let G be a d�regular graph every vertexhas degree d which is d�edge�connected� Prove that such a G is tough�meaning that removing any k vertices disconnects G into at most kconnected components for all k ��
�� Mader�s theorem ��LetG be a graph on n vertices such that jEGj �k � �n � k � � � �� where k is natural number with �k � � � n�By induction on n� prove that G has a k�vertex�connected subgraph�
�
Trees
��� De�nition and characterizations of trees
Even very abstract and elusive concepts in mathematics are oftengiven names from common language� Similarly as mathematical def�initions are not at all arbitrary� the name for a notion may be quiteimportant� Sometimes the name helps to communicate� on an in�tuitive level� some key property of the object which is not easy tonotice behind the formal de�nition� Other names may sound quiteillogical in today�s context without knowing their often convolutedhistory� For example� �elds in mathematics are neither green �eldsnor strawberry �elds nor any other kind of �elds most people may beused to� and it is hard to imagine why something in the plane shouldbe called a vertex �see Chapter � for the origin of this name� And� anun�tting name may lead one completely astray� In this chapter� thereader can judge how well mathematicians succeeded in choosing aname for a simple and fundamental graph�theoretic concepta tree�While trees in mathematics perhaps cannot match those in naturefor beauty or diversity� they still form quite a rich area in graph the�ory� and closely related concepts of trees appear in other branches ofmathematics and of computer science as well�
In graph theory� a tree is a graph similar to the ones in the fol�lowing drawings�
From these nature�inspired pictures� one may get quite a good idea
��� De nition and characterizations of trees ���
of what is meant by a tree in graph theory� But how do we de�nethis notion rigorously� Try it by yourself before reading further�
Perhaps the most usual de�nition is the following�
����� De�nition� A tree is a connected graph containing no cycle�
Don�t worry if your de�nition doesn�t match ours� A tree can bede�ned in several rather di�erent ways� Soon we will give even fourmore equivalent de�nitions�
Why should one de�ne a tree in several di�erent ways� First of all�the de�nition just given is somewhat unsuitable from several points ofview� For instance� it is not clear from it how we can check whethera given graph is a tree or not� The connectedness can be veri�ed bya simple algorithm� but deciding the existence of a cycle seems to bea problem� The alternative descriptions given below give very straight�forward algorithmic ways of recognizing trees� and they tell us severalinteresting properties of trees which may be useful in applications�Second� while a proof of the equivalence of the various de�nitions
is probably not very exciting reading� it provides good exercise mate�rial for students� own proofs according to our experience� The variousimplications in the proof are not formidably di�cult� but they are notcompletely easy either� and a student trying to prove one such implica�tion has plenty of opportunities to make and discover errors or gaps inthe proof� The proof given below also illustrates how one can proceedin proving the equivalence of several statements�Third� the equivalent characterizations of trees below are simple
but they show samples of �good� characterizations of a mathematicalobject one should look for� di�cult major theorems in several areas havea formally similar pattern�
Here are the promised equivalent de�nitions of a tree� The mostremarkable of them is perhaps the one saying that among connectedgraphs� a tree can be recognized simply by counting its edges andvertices�
����� Theorem �Tree characterizations�� The following condi�
tions are all equivalent for a graph G � �V�E�
�i� G is a tree�
�ii� �Path uniqueness�
For every two vertices x� y � V � there exists exactly one path
from x to y�
�iii� �Minimal connected graph�
The graph G is connected� and deleting any of its edges gives
rise to a disconnected graph�
�� Trees
�iv� �Maximal graph without cycles�
The graph G contains no cycle� and any graph arising from G by
adding an edge �i�e� a graph of the form G%e� where e � �V�
�nE�already contains a cycle�
�v� �Euler�s formula�
G is connected and jV j � jEj% ��
Note that this theorem not only describes various properties oftrees� such as �any tree on n vertices has n� � edges�� but also listsproperties equivalent to De�nition ������ so for instance it says �Agraph on n vertices is a tree if and only if it is connected and hasn� � edges��
Proving equivalences of various pairs of statements in Theorem �����seems far from trivial for beginners� and all sorts of shortcomings appearin attempts at such proofs� Here is a hypothetical example� Considerthe following implication� �If G is a tree� then any two vertices of G canbe connected by exactly one path�� Most people quickly notice thatsince G is connected� any two vertices can be connected by at leastone path� Then� if the proof is being created from the interaction of astudent with the teacher� dialog of the following sort often develops�
S�� �We proceed by contradiction� If u and v are two vertices in G thatcan be connected by two di�erent paths� then G contains a cycle�Hence the implication holds��
T�� �But why must there be a cycle in G if u and v are connected bytwo distinct paths��
S�� �Well� the two paths together contain a cycle��
For the teacher� this is not at all easy to argue with� in particularbecause it�s true and� moreover� �obvious from a picture��
T� �But why� Can you prove it rigorously� In your picture� there isindeed a cycle� and I can�t show you a graph with no cycle and withtwo paths between u and v either� but isn�t it possible that someextraterrestrians� much more clever than me and you and all otherpeople together� can construct such a graph��
Suggestions of didactically more convincing ways of arguing are wel�come� In fact� a rigorous proof is not entirely trivial� but it seems thatthe message most di�cult to get through is that there really is some�thing to prove� As you will see� in our proof of Theorem ����� below wepreferred to avoid this direct argument�
We now begin with the proof of Theorem ������ Since there aremany implications to prove� it is important to organize the proofsuitably� The basic idea in all steps is to proceed by induction onthe number of vertices of the considered graph� and to �tear o�� a
��� De nition and characterizations of trees ���
vertex of degree � in the inductive step� In few simple lemmas below�we prepare the ground for this method�
Let us call a vertex of degree � in a graph G an end�vertex of G ora leaf of G� We begin with the following almost obvious observation�
����� Lemma �Endvertex lemma�� Each tree with at least �vertices contains at least � end�vertices�
Proof� Let P � �v�� e�� v�� � � � � et� vt be a path of the maximumpossible length in a tree T � �V�E� Clearly the length of the pathP is at least �� and so in particular v� � vt� We claim that both v�and vt are end�vertices� This can be shown by contradiction� if� forexample� v� is not an end�vertex� then there exists an edge e � fv�� vgcontaining the vertex v� and di�erent from the �rst edge e� � fv�� v�gof the path P � Then either v is one of the vertices of the path P � i�e�v � vi� i � � �in this case the edge e together with the portion ofthe path P from v� to vi form a cycle� or v � fv�� � � � � vtgin thatcase we could extend P by adding the edge e� In both cases we thusget a contradiction� �
Let us remark that the end�vertex lemma does not hold for in�nitetrees the proof just given fails because a path of the maximum lengthneed not exist� For instance� the �one�sided in�nite path� has only oneend�vertex
� � �
and the �two�sided in�nite path� has none�
� � �� � �
We only consider �nite graphs here� however�
Next� we recall a notation from Section ���� if G � �V�E is agraph and v is a vertex of G� then G�v stands for the graph arisingfrom G by deleting the vertex v and all edges containing it� In casev is an end�vertex of a tree T � the graph T � v arises by deleting thevertex v and the single edge containing v�
����� Lemma �Treegrowing lemma�� The following two state�
ments are equivalent for a graph G and its end�vertex v�
�i� G is a tree
�ii� G� v is a tree�
��� Trees
Proof� This is also quite easy� First we prove the implication�i� �ii� The graph G is a tree� and we want to prove that G � vis a tree as well� Consider two vertices x� y of G� v� Since G is con�nected� x and y are connected by a path in G� This path cannotcontain a vertex of degree � di�erent from both x and y� and so itdoesn�t contain v� Therefore it is completely contained in G�v� andwe conclude that G�v is connected� Since G has no cycle� obviouslyG� v cannot contain a cycle� and thus it is a tree�
It remains to prove the implication �ii� �i� Let G�v be a tree�By adding the end�vertex v back to it� no cycle can be created� Wemust also check the connectedness of G� but this is obvious too� anytwo vertices distinct from v were connected already in G � v� anda path to v from any other vertex x is obtained by considering the�single neighbor v� of v in G� connecting it to x by a path in G� v�and extending this path by the edge fv�� vg� �
This lemma allows us to reduce a given tree to smaller and smallertrees by removing end�vertices successively� Now we are going toapply this device�
Proof of Theorem ������ We prove that each of the statements�ii��v is equivalent to �i� This� of course� proves the mutual equiva�lence of all the statements� The proofs go by induction on the numberof vertices of G using the tree�growing lemma ������ As for the in�duction basis� we note that all the statements are valid for the graphwith a single vertex�
First let us see that �i implies all of �ii��v� To this end� let Gbe a tree with at least � vertices� let v be one of its end�vertices� andlet v� be the single neighbor of v in G� Suppose that the graph G�valready satis�es �ii��v� this is our inductive hypothesis�
In this situation� the validity of �ii� �iii� and �v for G can beconsidered obvious �we leave a detailed argument to the reader�
As for �iv� we do not even need the inductive hypothesis forG�v�Since G is connected� any two vertices x� y � V �G can be connectedby a path� and if fx� yg � E�G then the edge fx� yg together withthe just�mentioned path creates a cycle� This proves the implication�i� �iv�
Let us now prove that each of the conditions �ii��v implies �i�In �ii and �iii we already assume connectedness� Moreover� a graphsatisfying �ii or �iii cannot contain a cycle� For �ii� this is becausetwo vertices in a cycle can be connected by two distinct paths� and
��� De nition and characterizations of trees ���
for �iii� the reason is that by omitting an edge in a cycle we obtaina connected graph� Thus we have already proved the equivalence of�i through �iii�
In order to verify the implication �iv��i� it su�ces to checkthat G is connected� For this� we can use the argument by whichwe have proved �i��iv turned upside down� If x� y � V �G are twovertices� either they are connected by an edge� or the graphG%fx� ygcontains a cycle� and removing the edge fx� yg from this cycle givesa path from x to y in G�
Finally the implication �v��i is again proved by induction onthe number of vertices� Let us consider a connected graph G satisfy�ing jV j � jEj% � � �� The sum of the degrees of all vertices is thus�jV j � � �why�� This means that not all vertices can have degree �or larger� and since all the degrees are at least � �by connectedness��there exists a vertex v of degree exactly �� i�e� an end�vertex of thegraph G� The graph G� � G � v is again connected and it satis�esjV �G�j � jE�G�j%�� Hence it is a tree by the inductive hypothesis�and thus G is a tree as well� �
Exercises
�� Draw all trees with vertex set f�� �� �� �g� and all pairwise noniso�morphic trees on � vertices�
�� Prove that any graph G � V�E having no cycles and satisfyingjV j � jEj� � is a tree�
�� �Let n �� Prove that a graph G on n vertices is a tree if and only ifit is not isomorphic to Kn and adding any edge on the same vertexset not present in G creates exactly one cycle�
�� Prove that a graph on n vertices with c components has at least n� cedges�
�� Suppose that a tree contains a vertex of degree k� Show that it has atleast k end�vertices�
�� Let T be a tree with n vertices� n �� For a positive integer i� let pibe the number of vertices of T of degree i� Prove
p� � p� � �p� � � � � � n� �pn�� � ��
This provides an alternative proof of the end�vertex lemma�
�� King Uxamhwiashurh had � sons� � of his male descendants had �sons each� �� had � sons� and all others died childless� How many maledescendants did King Uxamhwiashurh have�
��� Trees
�� Consider the following two conditions for a sequence d�� d�� � � � � dn ofstrictly positive integers where n ��i There exists a tree with score d�� d�� � � � � dn�
iiPn
i�� di � �n� ��The goal is to show that these conditions are equivalent and so thereis a very simple way to tell sequences that are scores of trees fromthose that aren�t�
a Why does i imply ii�
b Why is the following �proof� of the implication ii�i insu�cientor� rather� makes no sense� We proceed by induction on n� The basecase n � � is easy to check� so let us assume that the implication holdsfor some n �� We want to prove it for n��� If D � d�� d�� � � � � dn isa sequence of positive integers with
Pni�� di � �n� �� then we already
know that there exists a tree T on n vertices with D as a score� Addanother vertex v to T and connect it to any vertex of T by an edge�obtaining a tree T � on n�� vertices� Let D� be the score of T �� We knowthat the number of vertices increased by �� and the sum of degrees ofvertices increased by �the new vertex has degree � and the degree ofone old vertex increased by �� Hence the sequence D� satis�es condition�ii and it is a score of a tree� namely of T �� This �nishes the inductivestep�
c �Prove ii�i��� Suppose we want to prove that any connected graph G � V�E withjV j � jEj� � is a tree� i�e� the implication v�i in Theorem ������What is wrong with the following proof�
We already assume that the considered graph is connected� so all we needto prove is that it has no cycle� We proceed by induction on the numberof vertices� For jV j � �� we have a single vertex and no edge� and thestatement holds� So assume the implication holds for any graph G �V�E on n vertices� We want to prove it also for a graph G� � V �� E�arising from G by adding a new vertex� In order that the assumptionjV �j � jE�j�� holds for G�� we must also add one new edge� and becausewe assume G� is connected� this new edge must connect the new vertexto some vertex in V � Hence the new vertex has degree � and so it cannotbe contained in a cycle� And because G has no cycle �by the inductivehypothesis� we get that neither does G� have a cycle� which �nishes theinduction step�
��� Isomorphism of treesAs we have mentioned in Section ���� no fast algorithm is known for de�ciding whether two given graphs are isomorphic or not� For some specialclasses of graphs e�cient algorithms exist� however� One of these classes
��� Isomorphism of trees ���
is trees� In fact� many perhaps most algorithmic problems which areintractable for general graphs can be solved relatively easily for trees�
In this section we demonstrate a fast and simple algorithm for testingthe isomorphism of two given trees T and T �� For a given tree T � thealgorithm computes a sequence of �s and �s of length �n� calledthe code of the tree T � Isomorphic trees yield identical sequences�while nonisomorphic ones receive distinct sequences� In this way� thetesting for isomorphism is reduced to a simple sequence comparison�
Next� we introduce a number of specialized notions� each with aparticular name� This is quite usual in algorithmic graph theory� wheremany notions arose from various applications and where the terminologyis quite diverse�
A rooted tree is a pair �T� r� where T is a tree and r � V �T is adistinguished vertex of T called the root� If fx� yg � E�T is an edgeand the vertex x lies on the unique path from y to the root� we saythat x is the father of y �in the considered rooted tree and y is ason of x�
A planted tree is a rooted tree �T� r plus some its �xed drawing inthe plane� In this drawing� the root is marked by an arrow pointingdownwards� and the sons of each vertex all lie above that vertex�
For those who don�t like this de�nition� note that a planar drawingof a tree is fully described� up to a suitable continuous deformation ofthe plane� by the left�to�right order of the sons of each vertex� A plantedtree is thus a rooted tree in which every vertex v is assigned a linearordering of its sons� Thus� we can formally write a planted tree as atriple T� r� � where is a collection of linear orderings� one linearordering for the set of sons of each vertex�
For each of the above�de�ned types of trees� an isomorphism isde�ned in a slightly di�erent way� Let us recall that a mappingf �V �T � V �T � is an isomorphism of trees T and T � if f is abijection �i�e� it is one�to�one and onto satisfying fx� yg � E�T if and only if ff�x� f�yg � E�T �� The existence of such an iso�morphism is written T �� T �� An isomorphism of rooted trees �T� rand �T �� r� is an isomorphism f of the trees T and T � for which wehave� moreover� f�r � r�� This is denoted by �T� r ��� �T �� r�� Anisomorphism of planted trees is an isomorphism of rooted trees thatpreserves the left�to�right ordering of the sons of each vertex� Thefact that two planted trees are isomorphic in this sense is denotedby �T� r� ���� �T �� r�� ��
The de�nitions of ��� ���� and ���� are successively stronger and
��� Trees
stronger� This can be best understood in the following small exam�ples�
�� ����but
but��� �����
The de�nition of the isomorphism of planted trees is most re�strictive� and thus the coding of these trees is easiest� The followingmethod assigns a certain code to each vertex of a planted tree� Thecode of the whole tree is then de�ned as the code of the root�
K�� Each end�vertex distinct from the root is assigned ���
K�� Let v be a vertex with sons v�� v�� � � � � vt �written in the left�to�right order� If Ai is the code of the son vi� then the vertex vreceives the code �A�A� � � � At��
The process of a successive building of a code is illustrated below�
� �
�
�
�
� �
�
�
� � ��
� �
�
�
� � ��
� �� � ��
� �
�
�
� � ��
� �� � ��
� �� � �� ��
Clearly� isomorphic planted trees have been assigned the same codes�because in the code construction� we only used properties of a plantedtree preserved by the isomorphism of planted trees�
��� Isomorphism of trees ���
Now we show how the original planted tree can be reconstructedfrom the resulting code� In this way� we prove that nonisomorphicplanted trees are assigned distinct codes� We proceed by inductionon the length of the code�
The shortest possible code� ��� corresponds to the planted treewith a single vertex� In an induction step� suppose that we are givena code k of length ��n % �� This code has the form �A �� whereA � A�A� � � � At is a concatenation of codes of several planted trees�The part A� can be identi�ed as the shortest initial segment of thesequence A containing the same number of �s and �s� Similarly� A�
is the next shortest segment with the number of �s and �s balanced�and so on� By the inductive hypothesis� each Ai corresponds to aunique planted tree� The planted tree coded by the code k has asingle root r� and this root has as sons the roots r�� r�� � � � � rt of theplanted trees coded by A�� A�� � � � � At� respectively �in the left�to�right order� Hence the code uniquely determines a planted tree�
Decoding by the arrow method�We present an intuitive pictorialprocedure for reconstructing a planted tree from its code�In a given code sequence� we replace every by the arrow ��� and
every � by the arrow ���� Next� we take this sequence of arrows asinstructions for drawing a tree� When encountering an ���� we drawan edge from the current point upwards and to the right of the partsalready drawn from that point� For a ���� we follow an already drawnedge downwards� The whole procedure is illustrated in the followingpicture�
����������������
�
��
��
����������������
The procedure draws the root�s arrow as well� since a one�point treehas the code ��
We have studied the isomorphism of planted trees in some detail�since the algorithm for planted trees easily leads to an algorithm forrooted trees� For a rooted tree �T� r� we build its code in a similarway to the method for planted trees� but the rule K� is replaced bythe following modi�cation�
��� Trees
K��� Suppose that each son w of a vertex v has already beenassigned a code A�w� Let the sons of v be denoted byw�� w�� � � � � wt� in such a way that A�w� � A�w� � � � � �A�wt� The vertex v receives the code �A� A� � � � At �� whereAi � A�wi�
Here A � B means that the sequence A is less than or equal tothe sequence B in some �xed linear ordering of all �nite sequencesof �s and �s� For de�niteness� we can use the so�called lexicographic
ordering� Two �distinct sequences A � �a�� a�� � � � � an and B ��b�� b�� � � � � bm are compared as follows�
� If A is an initial segment of B then A � B� If B is an initialsegment of A then B � A� �For example� we have ���� � �����and � � �����
� Otherwise� let j be the smallest index with aj � bj � Then ifaj � bj we let A � B� and if aj � bj we let A � B� �Forexample� we have ��� � � and ����� � ������
We have to check that two rooted trees are isomorphic if and onlyif they have the same codes� This can be done quite similarly as forplanted trees� and we leave it to the reader�
We now turn our attention to coding trees without a root�� Ourtask would be greatly simpli�ed if we could identify a vertex whichwould play the role of the root� and which would be preserved byany isomorphism� For trees� such a distinguished vertex can indeedbe found �well� not always� but the exceptional cases can be char�acterized and they can be handled slightly di�erently� The relevantde�nitions can be useful also in other contexts� so we formulate themfor general graphs rather than just for trees�
For a vertex v of a graph G� let the symbol exG�v denote themaximum of the distances of v from other vertices of G� The numberexG�v is called the excentricity of the vertex v in the graph G� Wecan imagine the vertices with a large excentricity as lying on theperiphery of G�
Now let C�G denote the set of all vertices of G with the minimumexcentricity� The set C�G is called the center� of G� The example
�In the literature� the term free tree is sometimes used if one speaks about atree and wants to emphasize that it is not considered as a rooted tree�
�The excentricity of the vertices of the center is called the radius of thegraph G�
��� Isomorphism of trees ���
of a cycle �and many other graphs shows that sometimes the centermay coincide with the whole vertex set� However� for trees� we have
Proposition� For any tree T � C�T has at most � vertices� If C�T consists of � vertices x and y then fx� yg is an edge�
Proof� We describe a procedure for �nding the center of a tree�Let T � �V�E be a given tree� If T has at most � vertices� thenits center coincides with the vertex set and the proposition holds�Otherwise let T � � �V �� E� be the tree arising from T by removingall leaves� Explicitly�
V � � fx � V � degT �x � �g�E� � ffx� yg � E� degT �x � � and degT �y � �g�
We clearly have V �T � � �� since not all vertices of T can be leaves�Further� for any vertex v� the vertices most distant from v are nec�essarily leaves� and hence for each v � V � we get
exT �v � exT ��v % ��
In particular� we have C�T � � C�T � If T � has at least � vertices werepeat the construction just described� otherwise we have found thecenter of T � �
We can now specify the coding of a tree T �
� If the center of T is a single vertex� v� then we de�ne the codeof T to be the code of the rooted tree �T� v�
� If the center of T consists of an edge e � fx�� x�g� we considerthe graph T � e� This graph has exactly � components T� andT�� the notation is chosen in such a way that xi � V �Ti� Letthe letter A denote the code of the rooted tree �T�� x� and theletter B the code of the rooted tree �T�� x�� If A � B in thelexicographic ordering� the tree T is coded by the code of therooted tree �T� x�� and for A � B it is coded by the code of�T� x��
This �nishes the coding procedure for trees�The decoding is done in exactly the same way as for planted trees
�we then obtain a �canonical� drawing of the considered tree� Sincean isomorphism maps a center to a center and since we have alreadyseen that the coding works properly for rooted trees� it is easy to seethat two trees have the same code if and only if they are isomorphic�
�� Trees
The algorithms for the isomorphism of various types of trees ex�plained in this section can be implemented in such a way that thenumber of elementary steps computer instructions� say is bounded bya linear function of the total number of vertices of the input trees�Several more classes of graphs are known for which the isomorphism
problem can be solved e�ciently� Perhaps the most important examplesare the class of all planar graphs and the class of all graphs with maxi�mum degree bounded by a small constant� Here the known algorithmsfor isomorphism testing are fairly complicated�
Exercises
�� a Find an asymmetric tree� i�e� a tree with a single identical auto�morphism see Exercise ������ with at least � vertices�
b Find the smallest possible number of vertices a tree as in a canhave i�e� prove that no smaller tree can be asymmetric�
�� Find two nonisomorphic trees with the same score�
�� A rooted tree is called binary if each nonleaf vertex has exactly � sons�
a Draw all nonisomorphic binary trees with � vertices�
b Characterize the codes of binary trees�
�� Prove in detail that isomorphic trees not rooted receive the samecode by the explained procedure� and nonisomorphic trees get distinctcodes�
�� ��CS Let A�� � � � � At be sequences of s and �s possibly of di�erentlengths� Let n denote the sum of their lengths� Devise an algorithmthat sorts these sequences lexicographically in On steps� One stepmay only access one term of some Ai� it is not possible to manipulatea whole sequence of s and �s at once�
�� Prove that there exist at most �n pairwise nonisomorphic trees on nvertices�
�� Let T � V�E be a tree and v some vertex of T � Put
�v � maxjV T�j� jV T�j� � � � � jV Tkj�where T�� � � � � Tk are all the components of the graph T � v� The cen�troid of the tree T is the set of all vertices v � V with the minimumvalue of �v�
a �Prove that the centroid of any tree is either a single vertex or �vertices connected by an edge�
b Is the centroid always identical to the center�
c Prove that if v is a vertex in the centroid then �v � �� jV T j�
��� Spanning trees of a graph ���
��� Spanning trees of a graph
A spanning tree is one of the basic graph constructions�
����� De�nition� Let G � �V�E be a graph� An arbitrary tree of
the form �V�E�� where E� � E� is called a spanning tree of the
graph G� So a spanning tree is a subgraph of G that is a tree and
contains all vertices of G�
Obviously� a spanning tree may only exist for a connected graphG�It is not di�cult to show that every connected graph has a spanningtree� We prove it by giving two �fast algorithms for �nding a span�ning tree of a given connected graph� In the subsequent sections wewill need variants of these algorithms� so let us study them carefully�
����� Algorithm �Spanning tree�� Let G � �V�E be a graphwith n vertices and m edges� We order the edges of G arbitrarily intoa sequence �e�� e�� � � � em� The algorithm successively constructs setsof edges E�� E�� � � � � E�
We let E� � �� If the set Ei�� has already been found� the set Ei
is computed as follows�
Ei �
�Ei�� � feig if the graph �V�Ei�� � feig has no cycleEi�� otherwise�
The algorithm stops either if Ei already has n� � edges or if i � m�i�e� all edges of the graph G have been considered� Let Et denotethe set for which the algorithm has stopped� and let T be the graph�V�Et�
����� Proposition �Correctness of Algorithm ������� If Algo�
rithm ����� produces a graph T with n�� edges then T is a spanning
tree of G� If T has k � n� � edges then G is a disconnected graphwith n� k components�
Proof� According to the way the sets Ei are created� the graphG contains no cycle� If k � jE�T j � n � � then T is a tree byTheorem ������v� and hence it is a spanning tree of the graph G� Ifk � n � �� then T is a disconnected graph whose every componentis a tree �such a graph is called a forest� It is easy to see that it hasn� k components�
We prove that the vertex sets of the components of the graph Tcoincide with the vertex sets of the components of the graph G� Forcontradiction� suppose this is not true� and let x and y be vertices
��� Trees
lying in the same component of G but in distinct components of T �Let C denote the component of T containing the vertex x� and con�sider some path �x � x�� e�� x�� e�� � � � � e�� x� � y from x to y in thegraph G� as in the following picture�
xy
xi e
C
Let i be the last index for which xi is contained in the component C�Obviously i � �� and hence xi� � C� The edge e � fxi� xi�g thusdoes not belong to the graph T � and so it had to form a cycle withsome edges already selected into T at some stage of the algorithm�Therefore the graph T%e also contains a cycle� but this is impossibleas e connects two distinct components of T � This provides the desiredcontradiction� �
Complexity of the algorithm� We have just shown that Algo�rithm ����� always computes what it is supposed to compute� i�e� aspanning tree of the input graph� But if we really needed to �nd span�ning trees for some large graphs� should we choose this algorithm andspend our time programming it� or our money by buying some existingcode�To answer such a question is no simple matter� and algorithms are
compared according to di�erent� and often contradictory� criteria� Forinstance� it is important to consider the clarity and simplicity of thealgorithm a complicated or obscure algorithm easily leads to program�ming errors� the robustness how do rounding errors or small changesin the input data in�uence the correctness of the output�� memoryrequirements� and so on� Perhaps the most common measure of com�plexity of an algorithm is its time complexity� which means the numberof elementary operations such as additions� multiplications� compar�isons of two numbers� etc� the algorithm needs for solving the inputproblem� Most often the worst�case complexity is considered� i�e� thenumber of operations needed to solve the worst possible problem� oneexpressly chosen to make the algorithm slow� for a given size of input�For computing a spanning tree� the input size can be measured as thenumber of vertices plus the number of edges of the input graph� Insteadof �worst�case time complexity� we will speak brie�y of �complexity��since we do not discuss other types of complexity�The complexity of an algorithm can seldom be determined precisely�
In order that we could even think of doing it� we would have to deter�mine exactly what the allowed primitive operations are so� in principle�
��� Spanning trees of a graph ���
we would restrict ourselves to a speci�c computer� and also we wouldhave to describe the algorithm in the smallest details including variousroutine steps� that is� essentially look at a concrete program� Even ifwe did both these things� determining the precise complexity is quitelaborious even for very simple algorithms� For these reasons� the com�plexity of algorithms is only analyzed asymptotically in most cases� Wecould thus say that some algorithm has complexity On���� anotherone On logn� and so on here n is a parameter measuring the size ofthe input�For a real assessment of algorithms� it is usually necessary to com�
plement such a theoretical analysis by testing the algorithm for variousinput data on a particular computer� For example� if the asymptoticanalysis yields complexity On� for one algorithm and On log� n foranother then the second algorithm looks clearly better at �rst sight be�cause the function n log� n grows much more slowly than n�� But if theexact complexity of the �rst algorithm were� say� n� � �n and of thesecond one � nlog� n
�� the superiority of the second algorithm willonly show for n � � � � � and such a superiority is quite illusory froma practical point of view�Let us try to estimate the asymptotic complexity of Algorithm ������
We have described the algorithm on a �high level�� however� Thisdoesn�t refer to a prestigious social position but to the fact that wehave used� for instance� a test of whether a given set of edges containsa cycle� which cannot be considered an elementary operation even witha very liberal approach� The complexity of the algorithm will thus de�pend on our ability to realize such a complex operation by elementaryoperations�For our Algorithm ������ we may note that it is not necessary to store
all the edge sets Ei� and that all of them can be represented by a singlevariable say� a list of edges which successively takes values E�� E�� � � ��The only signi�cant question is how to test e�ciently whether addinga new edge ei creates a cycle or not� Here is a crucial observation� acycle arises if and only if the vertices of the edge ei belong to the sameconnected component of the graph V�Ei��� Hence we need to solvethe following problem�
����� Problem UNION�FIND problem� Let V � f�� �� � � � � ngbe a set of vertices� Initially� the set V is partitioned into ��elementequivalence classes� that is� no distinct vertices are considered equiva�lent� Design an algorithm which maintains an equivalence relation on Vin other words� a partition of V into classes in a suitable data struc�ture� in such a way that the following two types of operations can beexecuted e�ciently�
i UNION Make two given nonequivalent vertices i� j � V equiva�lent� i�e� replace the two classes containing them by their union�
��� Trees
ii Equivalence testing�FIND Given two vertices i� j � V � decidewhether they are currently equivalent�
A new request for an operation is input to the algorithm only after ithas executed the previous operation�
Our Algorithm ����� for �nding a spanning tree needs at most n� �operations UNION and at most m operations FIND�We describe a quite simple solution of Problem ������ In the be�
ginning� we assign distinct marks to the vertices of V � say the marks�� �� � � � � n� During the computation� the marks will always be assignedso that two vertices are equivalent if and only if they have the samemark� Thus� equivalence testing FIND is a trivial comparison of marks�For replacing two classes by their union� we have to change the marksfor the elements of one of the classes� So� if the elements of each class arealso stored in a list� the time needed for the mark�changing operationis proportional to the size of the class whose marks are changed�For a very rough estimate of the running time� we can say that no
class has more than n elements� so a single UNION operations neverneeds more than On time� For n� � UNION operations and m FINDoperations we thus get the bound On� �m� One inconspicuous im�provement is to maintain also the size of each class and to change marksalways for the smaller class� For such an algorithm� one can show a muchbetter total bound� On logn�m Exercise �� The best known solu�tion of Problem ������ due to Tarjan� needs time at most On�n�mfor m FIND and n� � UNION operations see e�g� Aho� Hopcroft� andUllman ���� where �n is a certain function of n� We do not give thede�nition of �n here� we only remark that �n does grow to in�nitywith n�� but extremely slowly� much more slowly than functions likelog logn� log log logn� etc� For practical purposes� the solution describedabove with re�marking the smaller class may be fully satisfactory�
Let us present one more algorithm for spanning trees� perhapseven a simpler one�
����� Algorithm �Growing a spanning tree�� Let a given graphG � �V�E have n vertices and m edges� We will successively con�struct sets V�� V�� V�� � � � � V of vertices and sets E�� E�� E�� � � � � Eof edges� We let E� � � and V� � fvg� where v is an arbitrary vertex�
Having already constructed Vi�� and Ei��� we �nd an edge ei �fxi� yig � E�G such that xi � Vi�� and yi � V n Vi��� and weset Vi � Vi�� � fyig� Ei � Ei�� � feig� If no such edge exists� thealgorithm �nishes and outputs the graph constructed so far� T ��Vt� Et�
����� Proposition �Correctness of Algorithm ������� If the al�
gorithm �nishes with a graph T with n vertices� then T is a spanning
��� The minimum spanning tree problem ���
tree of G� Otherwise G is a disconnected graph and T is a spanning
tree of the component of G containing the initial vertex v�
Proof� The graph T is a tree because it is connected and has theright number of edges and vertices� If T has n vertices� it is a spanningtree� so let us assume that T has +n � n vertices� It remains to showthat V �T is the vertex set of a component of G�
Let us suppose the contrary� let there be an x � V �T and ay � V �T connected by a path in the graph G� As in the proof ofProposition ������ we �nd an edge e � fxj � yjg � E�G on this pathsuch that xj � V �T and yj � V n V �T � The algorithm could thushave added the edge e and the vertex yj to the tree� and shouldnot have �nished with the tree T � This contradiction concludes theproof� �
Remark� The details of the algorithm just considered can be designedin such a way that the running time is On�m see Exercise ��
Exercises
�� Prove that if Problem ����� is solved by the described method alwayschanging the marks for the smaller class� then the total complexity ofn� � UNION operations is at most On logn�
�� ��CS Design the details of Algorithm ����� is such a way that the run�ning time is On � m in the worst case� This may require someknowledge of simple list�like data structures�
�� From Exercise ������ we recall that a Hamiltonian cycle in a graph Gis a cycle containing all vertices of G� For a graph G and a naturalnumber k �� de�ne the graph G�k� as the graph with vertex set V Gand two distinct vertices connected by an edge if and only if theirdistance in G is at most k�
a �Prove that for each tree T � the graph T ��� has a Hamiltoniancycle�
b Using a� conclude that G��� has a Hamiltonian cycle for anyconnected graph G�
c Find a connected graph G such that G��� has no Hamiltonian cycle�
��� The minimum spanning tree problem
Imagine a map of your favorite region of countryside with some �����villages� Some pairs of villages are connected by gravel roads� in sucha way that each village can be reached from any other along these
��� Trees
roads� The county�s council decides to modernize some of these roadsto highways suitable for fast car driving� but it wants to invest aslittle money as possible under the condition that it will be possibleto travel between any two villages along a highway� In this way� wearrive at a fundamental problem called the minimum spanning tree
problem� This section is devoted to its solution�
Of course� you may object that your favorite part of the countrysidewas full of �rst�class expressways a long time ago� So you may considersome less advanced country� or �nd another natural formulation of theunderlying mathematical problem�
We also assume that the existing roads have no branchings outsidethe villages� and that the new roads can only be built along the oldones because of proprietary rights� say� Otherwise� it may be cheaperfor instance to connect four places like this
instead of like this
If we allowed the former kind of connection� we would arrive at a di�er�ent algorithmic problem called the Steiner tree problem� which turnsout to be much less tractable than the minimum spanning tree problem�
A mathematical formulation of the minimum spanning tree prob�lem requires that the notion of graph is enriched a bit� we will con�sider graphs with weighted edges� This means that for every edgee � E we are given a number w�e� called the weight of the edge e�The weight of an edge is usually a nonnegative integer or real num�ber� A graph G � �V�E together with a weight function w on itsedges� w�E � R� is sometimes called a network�
Let us formulate the above road�building problem in graph�theo�retic terms�
Problem� Given a connected graph G � �V�E with a nonnegativeweight function w on the edges� �nd a spanning connected subgraph�V�E� such that the sum
��� The minimum spanning tree problem ���
w�E� �Xe�E�
w�e ����
has the minimum possible value�
It is easy to see that there is always at least one spanning treeof G among the solutions of this problem� If the weights are strictlypositive� each solution must be a spanning tree� For instance� if alledges have weight �� then the solutions of the problem are exactly thespanning trees of the graph� and the expression ���� has minimumvalue jV j � ��
Hence� it su�ces to deal with the following problem�
����� Problem �Minimum spanning tree problem�� For a con�nected graph G � �V�E with a weight function w on the edges� �nda spanning tree T � �V�E� of the graph G with the smallest possiblevalue of w�E��
An attentive reader might have observed that here we do not assumenonnegativity of the weights� Indeed� the algorithms we are going to dis�cuss solve even this more general problem with arbitrary weights� Thereis more to this remark than meets the eye� many graph problems thatare easy for nonnegative weights turn into algorithmically intractableproblems if we admit weights with arbitrary signs� An example of sucha problem is �nding the shortest path in a network� where the lengthof a path is measured as the sum of the edge weights�
A given graph may have very many spanning trees �see Chapter �and it may seem di�cult to �nd the best one� It is not really sodi�cult� and nowadays it can be done by an easy modi�cation of thealgorithms from the previous section� We present several algorithms�A simple and very popular one is the following�
����� Algorithm �Kruskal�s or the �greedy� algorithm�� Theinput is a connected graph G � �V�E with edge weight function w�Let us denote the edges by e�� e�� � � � � em in such a way that
w�e� � w�e� � � � � � w�en�
For this ordering of edges� execute Algorithm ������
Before proving the correctness of Kruskal�s algorithm� which isnot completely easy� let us illustrate the algorithm with a small ex�ample�
��� Trees
Example� Let us apply Kruskal�s algorithm for the following net�work�
�
�
�
�
�
� �
�
One possible execution of the algorithm is shown in the next diagram�
����� Proposition �Correctness of Kruskal�s algorithm�� Al�
gorithm ����� solves the minimum spanning tree problem�
Proof� This proof is not really deep but it seems to require a con�centrated attention� for otherwise it is very easy to make a mistakein it �both the authors have a rich experience of it by presenting itin lectures�
Let T be the spanning tree found by the algorithm� and let Tbe any other spanning tree of the graph G � �V�E� We need toshow that w�E�T � w�E� T � Let us denote the edges of T bye��� e��� � � � � e�n�� in such a way that w�e�� � w�e�� � � � � � w�e�n���the edge e�i has been denoted by some ej in the algorithm� so thatit now has two names�� Similarly let e�� � � � � en�� be the edges of Tordered increasingly by weights�
We show that for i � �� � � � � n� �� we even have
w�e�i � w� ei� ����
This of course shows that T is a minimum spanning tree� For contra�diction� let us assume that ���� is not true� and let i be the smallestindex for which it is violated� i�e� w�e�i � w� ei� We consider the sets
E� � fe��� � � � � e�i��g� E � f e�� � � � � eig�
The graphs �V�E� and �V� E contain no cycles and� moreover�jE�j � i� �� j Ej � i�
��� The minimum spanning tree problem ���
For the desired contradiction it su�ces to show that there existsan edge e � E for which the graph �V�E� � feg contains no cycle�Then we obtain w�e � w� ei � w�e�i and this means that at themoment the edge e was considered in the algorithm we made a mis�take� There was no reason to reject e� and we should have selectedit instead of the edge e�i or earlier�
Therefore it is enough to show the following� If E�� E � �V�
�are
two sets of edges� such that the graph �V� E has no cycle and jE�j �j Ej� then some edge e � E connects vertices of distinct components of
the graph �V�E�� This can be done by a simple counting argument�Let V�� � � � � Vs be the vertex sets of the components of the graph�V�E�� We have �����E�
�Vj�
������ � jVj j � ��
and by summing these inequalities over j we get jE�j � n � s� Onthe other hand� since E has no cycles� we get����� E
�Vj�
������ � jVjj � ��
and therefore at most n� s edges of E are contained in some of thecomponents Vj� But since we assumed j Ej � jE�j� there is an edgee � E going between two distinct components� �
Kruskal�s algorithm is a prototype of the so�called greedy algorithm�At every step� it selects the cheapest possible edge among those allowedby the restrictions of the problem here �the graph should contain nocycle�� In general� �greedy algorithm� is a term for a strategy tryingto gain as much as possible at any given moment� never contemplatingthe possible disadvantages such a choice may bring in the future�� Fornumerous problems� this short�sighted strategy may fail completely� Forinstance� a greedy strategy applied for a chess game would mean inthe simplest form that a player would always take a piece wheneverpossible� and always the most valuable one� And by following such anaive play he would lose very soon�
�In the minimum spanning tree problem� a parsimonious algorithm wouldperhaps be a more appropriate name� since we always take the cheapest possibleedge� But greedy algorithm is a universally accepted name� It is derived fromsituations where one tries to maximize something by grabbing as much as possiblein each step� Since the minimizing and maximizing problems aren�t conceptuallyvery di�erent� it seems better to stick to the single term greedy algorithm inboth situations�
�� Trees
In this context� it seems somewhat surprising that the greedy al�gorithm �nds a minimum spanning tree correctly� The greedy strategymay be useful also for many other problems especially if we have nobetter idea� Often it at least yields a good approximate solution� Prob�lems for which the greedy algorithm always �nds an optimal solutionare studied in the so�called matroid theory� The reader can learn aboutit in Oxley ����� for instance�
Exercises
�� Analogously to the minimum spanning tree problem� de�ne the max�imum spanning tree problem� Formulate a greedy algorithm for thisproblem and show that it always �nds an optimal solution�
�� Prove that if T � V�E� is a spanning tree of a graph G � V�Ethen the graph T � e� where e is an arbitrary edge of E nE�� containsexactly one cycle�
�� Prove that if T is a spanning tree of a graph G then for every e �EG n ET there exists an e� � ET such that T � e� � e is aspanning tree of G again�
�� Let G be a connected graph with a weight function w on the edges�and assume that w is injective� Prove that the minimum spanning treeof G is determined uniquely�
�� �Let G be a connected graph with a weight function w on the edges�Prove that for each minimum spanning tree T of G� there is an initialordering of the edges in Kruskal�s algorithm such that the algorithmoutputs the tree T �
�� Let w and w� be two weight functions on the edges of a graph G �V�E� Suppose that we� � we� holds if and only if w
�e� �w�e�� for any two edges e�� e� � E� Prove that V�E� is a minimumspanning tree G for the weight function w if and only if V�E� is aminimum spanning tree of G for the weight function w�� This means�the solution to the minimum spanning tree problem only depends onthe ordering of edge weights�
�� CS Using the discussion of Algorithm ����� in the preceding section�design the details of Kruskal�s algorithm in such a way that its timecomplexity is On�m logn�
�� Consider an n�point set V in the plane� We de�ne a weight function onthe edge set of the complete graph on V � the weight of an edge fx� ygis the distance of the points x and y�
a �Show that no minimum spanning tree for this network has a vertexof degree � or higher�
�� Jarn��k�s algorithm and Bor�uvka�s algorithm ���
b �Show that there exists a minimum spanning tree whose edges donot cross�
�� �Let V be a set of n � � points in the unit square in the plane� Let T bea minimum spanning tree for V i�e� for the complete graph with edgeweights given by distances as in Exercise �� Show that the total lengthof the edges of T is at most �
pn� The constant � can be improved
signi�cantly� the best known estimate is about ���pn�O��
� � Let G � V�E be a graph and let w be a nonnegative weight functionon its edges�
a �Each set E� � E of pairwise disjoint edges i�e� sharing no verticesis called a matching in the graph G� Let wG denote the maximumpossible value of wE� for a matching E� � E� A greedy algorithmfor �nding a maximum matching works similar to Kruskal�s algorithmfor a maximum spanning tree� i�e� it considers edges one by one in theorder of decreasing weights� and it selects an edge if it has no commonvertex with the previously selected edges� Show that this algorithmalways �nds a matching with weight at least �
� wG�
b Show that the bound in a cannot be improved� that is� for anyconstant � � �
� there exists an input for which the greedy algorithm�nds a matching with weight smaller than � wG�
��� A set C � E in a graph G � V�E is called an edge cover if eachvertex v � V is contained in at least one edge e � C� Let us look for asmall edge cover by a greedy algorithm� if there is an edge containing �uncovered vertices take an arbitrary such edge� otherwise take any edgecovering some yet uncovered vertex� and repeat until all is covered�Show that the number of edges in a cover thus found is
a at most twice the size of the smallest possible cover�
b ��and even at most �� of the size of the smallest possible cover�
��� �A set D � V in a graph G � V�E is called a dominating set ifSeE� eD ��� e � V � Let us look for a small dominating set by a greedyalgorithm� we always select a vertex connected to the maximum pos�sible number of yet uncovered vertices� Show that for any number Cthere exists a graph for which jDGj CjDM j� where DG is a domi�nating set selected by the greedy algorithm and DM is a dominatingset of the smallest possible size� Start by �nding examples for smallspeci�c values of C�
��� Jarn��k�s algorithm and Bor�uvka�s algorithmWhat we call �Jarn')k�s algorithm� is mostly known under the name�Prim�s algorithm�� However� since Prim�s paper is dated ���� while
��� Trees
Jarn')k� already described the same algorithm in an elegant and preciseway in ��� continuing the work of Bor*uvka who published the �rstdocumented algorithm for the minimum spanning tree problem in �����we believe it is appropriate to use the name of the �rst inventor�
Nowadays� Jarn�!k�s algorithm can be viewed as a simple extensionof Algorithm ������
����� Algorithm �Jarn��k�s algorithm�� Proceed according to Al�gorithm ������ and always choose the newly added edge ei as an edgeof the smallest possible weight from the set ffx� yg � E�G� x �Vi��� y � Vi��g������ Proposition �Correctness of Jarn��k�s algorithm�� Jar�
n��k�s algorithm �nds a minimum spanning tree for every connected
network�
Proof� Let T � �V�E� be the spanning tree resulting from Jarn�!k�salgorithm� and suppose that the edges of E� are numbered e� throughen�� in the order they were added to T � For contradiction� supposethat T is not a minimum spanning tree�
Let T � be some minimum spanning tree� Let k�T � denote theindex k for which all the edges e�� e�� � � � � ek belong to E�T � butek� � E�T �� Among all minimum spanning trees� select one whichhas the maximum possible value of k and denote it by T � �V� E�Write k � k� T �
Now consider the moment in the algorithm�s execution when theedge ek� has been added to T � Let Tk � �Vk� Ek be the tree formedby the edges e�� � � � � ek� Then ek� has the form fx� yg� where x �V �Tk and y � V �Tk� Consider the graph T % ek�� This graphcontains some cycle C �since it is connected and has more than n��edges� and such a C necessarily contains the edge ek� �see alsoExercise ������
The cycle C consists of the edge ek� � fx� yg plus a path Pconnecting the vertices x and y in the spanning tree T � At least oneedge of the path P has one vertex in the set Vk and the other vertexoutside Vk� Let e be some such edge� Obviously e � ek�� and furtherwe know that e � E and ek� � E� see Fig� ���� Both the edges eand ek� connect a vertex of Vk with a vertex not lying in Vk� andby the edge selection rule in the algorithm we get w�ek� � w�e�
�An approximate pronunciation is YAR�neekh� and for Bor�uvka it is BOH�roof�kah�
�� Jarn��k�s algorithm and Bor�uvka�s algorithm ���
ek�
x
y
Vk
e
P
�T
Fig� ��� Illustration for the correctness proof of Jarn')k�s algorithm�
Now consider the graph T � � � T %ek��e� This graph has n��edges and� as is easy to check� it is connected� hence it is a spanningtree� We have w�E�T � � w� E�w�e%w�ek� � w� E� and thusT � is a minimum spanning tree as well� but with k�T � � k� T � Thiscontradiction to the choice of T proves Proposition ������
Warning� This is another proof of a slippery nature� make one stepslightly di�erently and the whole thing falls apart� �
Bor�uvka�s algorithm� In conclusion� let us mention the historically�rst algorithm for minimum spanning tree computation due to Bor*uvka�As is usual in science� the �rst method discovered was not the simplest�both Kruskal�s and in particular Jarn')k�s algorithm are conceptuallysimpler� But yet it was Bor*uvka�s algorithm that recently became astarting point for the theoretically fastest known algorithm for the min�imum spanning tree problem Karger� Klein� and Tarjan ����� This lat�ter algorithm is fairly complicated and uses a number of other ideaswhich we will not pursue here to make the computation fast�
����� Algorithm Bor�uvka�s algorithm� The input is a graph G �V�E with edge weight function w� We need to assume� moreover� thatdistinct edges get distinct weights� i�e� that the weight function is one�to�one� This assumption is not particularly restrictive� Each weight func�tion can be converted into a one�to�one function by arbitrarily smallchanges of the weights� which changes the weight of a minimum span�ning tree by an arbitrarily small amount� Alternatively� the algorithmcan be modi�ed to work with arbitrary weight functions� by adding asimple tie�breaking rule outlined in Exercise � below�The algorithm successively constructs sets E�� E�� � � � � E of edges�
beginning with E� � �
��� Trees
Suppose that the set Ei�� has already been computed� and letV�� � � � � Vt be the partition of the vertex set according to the compo�nents of the graph V�Ei��� Strictly speaking� this partition should alsohave the index i since it is di�erent in each step� but we omit this indexin order to make the notation simpler� For each set Vj of this partitionwe �nd the edge ej � fxj � yjg where xj � Vj � yj �� Vj whose weightis minimum among all edges of the form fx� yg� x � Vj � y � V n Vj itmay happen that ej � ej� for j �� j�� We put Ei � Ei�� � fe�� � � � � etg�The algorithm �nishes when the graph V�Ei has a single component�
The algorithm could also be called a �bubbles algorithm�� The graphG is covered by a collection of �bubbles�� In each step� we merge eachbubble with its nearest neighboring bubble�We will not prove the correctness of this algorithm� We only show
that the constructed graph has no cycle which� unlike the previousalgorithms� is not quite obvious� So suppose for contradiction that acycle arose in some step i� This means that there are pairwise distinctindices j�� j�� � � � � jk for which
xj��� � Vj���� yj��� � Vj���xj��� � Vj���� yj��� � Vj���
���xj�k��� � Vj�k���� yj�k��� � Vj�k�xj�k� � Vj�k�� yj�k� � Vj����
Here is an illustration�
Vj�k�
Vj��� Vj���
Vj���
xj��� yj���xj���
yj���� xj���yj�k�xj�k�
yj�k���
Since distinct edges have distinct weights� the edge ej��� always has thesmallest weight among the edges leaving the component Vj���� and inparticular� we get
wej��� � wej��� � � � � � wej�k� � wej����
This chain of strict inequalities cannot hold and so Bor*uvka�s algorithm�nds some spanning tree of G� With some more e�ort� it can be provedthat it �nds the minimum spanning tree� �
�� Jarn��k�s algorithm and Bor�uvka�s algorithm ���
Example� Consider the following network the weights are given aslabels of the edges�
��
�
� � ��
� ��
��
�
��
�� �
�� �
� � �
Jarn')k�s algorithm started in the upper left corner proceeds as follows�
Kruskal�s algorithm needs �� steps but only in � of them is a newedge added� Bor*uvka�s algorithm� on the other hand� is quite short�
But in each step we have to do much more work�
Exercises
�� General spanning tree algorithm Consider the following algorithm forthe minimum spanning tree problem� The input is a connected graphG � V�E with weight function w� We put E� � � Suppose thatEi�� has already been de�ned� Choose an arbitrary component Vi ofthe graph V�Ei��� select an edge ei of the minimum weight amongthe edges with one vertex in Vi and the other vertex not in Vi� and setEi � Ei�� � feig� Prove that V�En�� is a minimum spanning tree�Imitate the correctness proof for Jarn')k�s algorithm�
Check that this proves the correctness of both Kruskal�s and Jarn')k�salgorithm�
�� �Inverse� greedy algorithm Consider the following algorithm for theminimum spanning tree problem� The input is a connected graph G �V�E with weight function w� Label the edges e�� � � � � em in such away that we� � � � wem� Put E� � E� and
Ei �
�Ei�� n feig if the graph V�Ei�� n feig is connectedEi otherwise�
��� Trees
Prove that V�Em is a minimum spanning tree of G�
�� �Prove the correctness of Bor*uvka�s algorithm�
�� CS Design the details of Jarn')k�s algorithm in such a way that itstime complexity is Om�n logn this probably requires some basicknowledge of data structures�
�� a Prove that Bor*uvka�s algorithm has at most Ologn phases� i�e�the graph V�Ei is connected already for some i � Olog n�
b CS Design the details of Bor*uvka�s algorithm in such a way thatits time complexity is at most Om � n logn�
�� Tie�breaking in Bor*uvka�s algorithm Given an arbitrary weight func�tion on edges of a graph G � V�E� we choose an arbitrary orderinge�� e�� � � � � em of the edges once and for all� and we de�ne ei � ej ifeither wei � wej or both wei � wej and i � j�
a Formulate Bor*uvka�s algorithm with edges ordered by the linearordering � instead of the usual ordering � on the weights�b Check that the algorithm in a computes a spanning tree of G�
c Prove that the algorithm in a computes a minimum spanningtree of G with respect to the weight function w modify the proof inExercise ��
�
Drawing graphs in the plane
��� Drawing in the plane and on other surfaces
Often it is advantageous to draw graphs� As you can see� most ofthe graphs in this book are speci�ed by a picture �instead of a list ofvertices and edges� say� But so far we have been studying propertiesof graphs not related to their drawings� and the role of drawings waspurely auxiliary� In this chapter the subject of analysis will be thedrawing of graphs itself and we will mainly investigate graphs thatcan be drawn in the plane without edge crossings� Such graphs arecalled planar�
From the numerous pictures shown so far and from the informalde�nition given in Section ���� the reader might have gained a quitegood intuition about what is meant by a drawing of a graph� Such anintuition is usually su�cient if we want to show� say� that some graphis planar�we can simply draw a suitable picture of the graph with noedge crossings� However� if we want to prove� in a strictly logical way�that some graph is not planar� then we cannot do without a math�ematical de�nition of the notion of a drawing� based on other exactmathematical notions� Today�s mathematics is completely built from afew primitive notions and axioms of set theory�or at least the majorityof mathematicians try to ensure it is� So� for instance� the notion of a�plane� is being modeled as the Cartesian product R �R� Each realnumber is de�ned as a certain subset of the rationals� the rational num�bers are created from natural numbers� and �nally the natural numbersare de�ned as certain special sets produced from the empty set� Thisis seldom apparent in everyday mathematics� but if you look at a bookon the foundations of mathematics you can �nd it in there�
In order to introduce the notion of a drawing formally� we de�ne anarc �rst� this is a subset of the plane of the form � ����� �� �f��x� x � ��� ��g� where �� ��� �� � R� is an injective continuousmap of the closed interval ��� �� into the plane� The points ��� and��� are called the endpoints of the arc �
��� Drawing graphs in the plane
This de�nition� frightening as it may look� is very close to the in�tuitive notion of drawing� The interval � � �� can be thought of as atime interval during which we draw a line from the point to thepoint �� Then t is the position of the pencil�s tip at time t� Thecontinuity of the mapping means a continuous motion on the paper�ssurface in time� and the injectivity says that the line being drawn neverintersects itself�
����� De�nition� By a drawing of a graph G � �V�E we mean
an assignment as follows� to every vertex v of the graph G� assign a
point b�v of the plane� and to every edge e � fv� v�g � E� assign an
arc �e in the plane with endpoints b�v and b�v�� We assume that
the mapping b is injective �di�erent vertices are assigned distinctpoints in the plane�� and no point of the form b�v lies on any of the
arcs �e unless it is an endpoint of that arc� A graph together with
some drawing is called a topological graph��A drawing of a graph G in which any two arcs corresponding to
distinct edges either have no intersection or only share an endpoint
is called a planar drawing� A graph G is planar if it has at least oneplanar drawing�
We have given the above formal de�nition of a graph drawing a bit�for show�� in order to illustrate that the notion of a drawing can beincluded in the logical construction of mathematics� We will not con�tinue building the subsequent theory of planar graphs in a strictly log�ical way� though� We would have to use notions and results concerningplanar curves� These belong to a branch of mathematics called topol�ogy� Only very little from topology is usually covered in introductorymathematical courses� and we would have to introduce quite compli�cated machinery in order to do everything rigorously� Moreover� proofsof certain �intuitively obvious� statements are surprisingly di�cult� Forthese reasons� we will sometimes rely on the reader�s intuition in thesubsequent text� and we will ask the reader to believe in some valid�statements without a proof� A rigorous treatment can be found� for ex�ample� in the recent book by Mohar and Thomassen ����� Fortunately� inthe theory of graph drawing� the basic intuition about drawing seldomleads one astray�
A planar drawing is advantageous for a visualization of a graph�edge crossings in a nonplanar drawing could be mistaken for ver�tices� and in some applications where the drawing has a physical
�A planar graph with a given planar drawing� i�e� a topological planar graph�is sometimes called a plane graph�
�� Drawing in the plane and on other surfaces ���
meaning� edge crossings can be inadmissible �for instance� in thedesign of single�layer integrated circuits�
Faces of a graph drawing� Let G � �V�E be a topological planargraph� i�e� a planar graph together with a given planar drawing�Consider the set of all points in the plane that lie on none of the arcsof the drawing� This set consists of �nitely many connected regions�imagine that we cut the plane along the edges of the drawing�
F�F�
F�
�We say that a set A � R� is connected if for any two points x� y � Athere exists an arc � A with endpoints x and y� �Being connec�ted�� is an example of a topological notion� These regions will becalled the faces of the considered topological planar graph� The re�gion spreading out to in�nity� such as F� in the picture� is called theouter face �or the unbounded face of the drawing� and all the otherfaces are called inner faces �or bounded faces�
Let us stress that faces are de�ned for a given planar drawing�Faces are usually not de�ned for a nonplanar drawing� and also weshould not speak about faces for a planar graph without having aspeci�c drawing in mind�
Drawing on other surfaces� A graph can also be drawn on othersurfaces than the plane� Let us list some examples of interesting surfaces�Everyone knows the sphere i�e� the surface of a ball� The surface
of a tire�tube is scienti�cally called the torus��
�What we called a connected set is usually called an arc�connected set intopology� A connected set is de�ned as follows� A set A � R
� is connectedif no two disjoint open sets A�� A� � R
� exist such that A � A� � A� andA� � A �� � �� A� � A� For sets considered in this chapter� such as faces of agraph� both these notions of being connected coincide� and so we use the shortername�
�People with an US�centered worldview might want to speak about the surfaceof a doughnut� but since doughnuts in other countries �Australia� United King�dom� are often spherical� we don�t consider this name ��� politically correct�
�� Drawing graphs in the plane
If we take a long strip of paper� turn one of its ends by �� degrees�and glue it to the other end� we obtain an interesting surface called theM�obius band�
Other examples are a sphere with two handles�
after a suitable deformation� this is also the surface of a �fat �gure ���or the so�called Klein bottle�
Each of these surfaces can be created from a planar polygon by�gluing� and a suitable deformation� In the above examples� with theexception of the sphere with two handles� we would always start froma planar rectangle� and we would identify glue some its edges in asuitable way� We have already introduced the M&obius band using sucha procedure� and this method is also a basis for a rigorous de�nition ofsuch surfaces which we do not present here� For example� the toruscan be made as follows�
�� Drawing in the plane and on other surfaces ���
a b
cd
That is� we identify the opposite edges of the rectangle abcd� in such away that the edge ab is glued to the edge dc and the edge ad is gluedto the edge bc� The orientation of edges for gluing is usually marked byarrows� The arrows in the following picture mean that when gluing theedge ad to the edge bc� the point a goes to the point b and the point dgoes to c�
a
cd
b
The following picture once again indicates how to manufacture theM&obius band�
we only identify the two edges marked by arrows in such a way thatthe arrow directions are the same on the glued edge� The Klein bottleis produced by following the instructions of the next picture�
In fact� these are not quite honest directions for producing your ownKlein bottle� since the Klein bottle cannot be realized in the ��dimen�sional Euclidean space� The indicated gluing cannot be done in R�
unless the rectangle intersects itself as it does in the picture showingthe Klein bottle� Nevertheless� the de�nition of the Klein bottle by
��� Drawing graphs in the plane
gluing makes good sense mathematically� and the surface can be realizedin R�� say�There is a general theorem saying that any closed surface having no
�boundary points� and not �running to in�nity� anywhere� a scholarlyterm is �a compact ��manifold without boundary� can be created by asuitable gluing and deformation from a regular convex polygon� More�over� if the resulting surface is two�sided note that both the M&obiusband and the Klein bottle only have one side� then it can be continu�ously deformed into a sphere with �nitely many handles� The basics ofthis theory and a number of related topics are beautifully explained inthe book by Stillwell �����Graphs can be classi�ed according to the surfaces they can be drawn
on� As will be shown in the next section� neither the graph K�� thecomplete graph on � vertices� nor K���� the complete bipartite graph on��� vertices� is planar� But K� can be drawn on the torus� for instance�
and K��� on the M&obius band�
As we said above� these surfaces can be obtained by a suitable gluingof the edges of a rectangle� In order that our spatial imagination is notoverstrained� we can convert drawing on surfaces into a modi�ed planardrawing� where edges can �jump� among the glued rectangle edges� Thedrawings just shown can thus be recast as follows�
Let us remark that even the graph K��� can be drawn on the torus�
�� Drawing in the plane and on other surfaces ���
� � � �
a b c d
a b c d
a b c d
�
�
�
�
� �
K can be so drawn as well� see Exercise �� In general� we have
����� Proposition� Any graph can be drawn without edge crossingson a sphere with su�ciently many handles�
This proposition must be taken informally� since we gave no exactde�nition of a sphere with handles�
Informal proof� Let us draw the given graph G � V�E on thesphere� possibly with edge crossings� Let e�� e�� � � � � en be all edges hav�ing a crossing with another edge� For each edge ei� add a handle servingas a �bridge� for that edge to avoid the other edges� in such a way thatthe handles are disjoint and the edges drawn on handles do not crossanymore�
Since we deal with �nitely many edges only� it is easy to �nd suchhandles� �
Hence the following de�nition makes sense�
����� De�nition� The smallest number of handles that must be addedto the sphere so that a graph G can be drawn on the resulting surfacewithout edge crossings is called the genus� of the graph G�
In conclusion of this section� let us show that planar graphs areexactly graphs of genus � i�e� ones that can be drawn on the sphere� Thisbecomes quite obvious if we use the stereographic projection� We place
�The notion of genus is primarily used for surfaces� For example� the genusof a sphere with handles is the number of handles� Interestingly� ��dimensionalsurfaces were �rst systematically studied in connection with algebraic equations�The set of all complex solutions of a polynomial equation in � variables is typicallya ��dimensional surface� and its genus is crucial for various properties of theequation� The �di�cult� area of mathematics studying algebraic equations inthis spirit is called algebraic geometry �Cox� Little� and O�Shea � �� is a niceintroduction to the subject��
��� Drawing graphs in the plane
the sphere in the ��dimensional space in such a way that it touches theconsidered plane �� Let o denote the point of the sphere lying farthestfrom � the �north pole��
o
x
x�
�
Then the stereographic projection maps each point x �� o of the sphereto a point x� in the plane� where x� is the intersection of the line oxwith the plane �� For the point o� the projection is unde�ned� Thisde�nes a bijection between the plane and the sphere without the pointo� Given a drawing of a graph G on the sphere without edge crossings�where the point o lies on no arc of the drawing which we may assumeby a suitable choice of o� the stereographic projection yields a planardrawing of G� Conversely� from a planar drawing we get a drawing onthe sphere by the inverse projection�
Exercises
�� Find
a a planar graph all of whose vertices have degree ��
b �connected graphs as in a with arbitrarily many vertices�
�� a Check that the picture shown in the text indeed gives a drawingof K��� on the torus�
b Find a drawing of K on the torus�
c �Draw K on the torus�
�� �Let G be a planar Eulerian graph� Consider some planar drawing ofG� Show that there exists a closed Eulerian tour that never crossesitself in the considered drawing it may touch itself at vertices but itnever �crosses over to the other side��
�� Try to invent some suitable de�nition of a closed ��dimensional surface�Then look up what the usual de�nition is in a book on topology�
��� Cycles in planar graphs
We will investigate various combinatorial properties of planar graphs�Among others� it turns out that the notion of a planar graph itself
�� Cycles in planar graphs ���
can be equivalently de�ned by purely combinatorial means� withoutusing topological properties of the plane or intuition about graphdrawing�
Should the geometric de�nition of planar graphs be converted intoa combinatorial de�nition� we have to use some property of the planeconnecting geometry to combinatorics� Such a property is expressedby the Jordan curve theorem below� First� a de�nition� a Jordan
curve� is a closed curve without self�intersections� More formally� aJordan curve is de�ned as an arc whose endpoints coincide� i�e� acontinuous image of the interval ��� �� under a mapping f that isone�to�one except for the equality f�� � f���
����� Theorem �Jordan curve theorem�� Any Jordan curve kdivides the plane into exactly two connected parts� the interior
and the exterior of k� and k is the boundary of both the interior
and the exterior� �Both the interior and exterior will be called the
regions of k�� This means that if we de�ne a relation � on the set
R� n � by setting x � y if and only if x and y can be connected by
an arc disjoint from k� then � is an equivalence with � classes� one
of them being a bounded set and the other one an unbounded set�
This theorem is intuitively obvious� but its proof is by no meanssimple� although signi�cant simpli�cations have been found recently byThomassen ����� For some Jordan curves in the plane� the statement isvery evident�
but for others it is perhaps less obvious try �nding an arc connectingthe points and � and not intersecting the curve�
�Another common name for this object is a simple closed curve�
��� Drawing graphs in the plane
In order to illustrate that intuition is not always reliable for such�obvious� statements� let us mention a related theorem� An extension ofthe Jordan curve theorem� the Jordan�Sch�on�ies theorem� tells us thatfor any Jordan curve� the interior can be continuously deformed ontothe interior of the usual geometric circle� More precisely� there existsa continuous mapping whose inverse mapping is continuous as well� aso�called homeomorphism� between the closed region bounded by anyJordan curve and the ordinary circular disk� Similarly� one would expectthat if we de�ne a �topological sphere� as the image of the usual geo�metric sphere by an injective continuous map� such a thing will bounda region that can be continuously deformed onto the ordinary ball� Butthis is false�a counterexample is known under the name �Alexander�shorned sphere� see e�g� the excellent but somewhat more advancedbook by Bredon �����Let us remark that the di�culties with proving the Jordan curve the�
orem mainly stem from the considerable generality of the notion of anarc� We admit an arbitrary injective continuous mapping of the unit in�terval in the de�nition of an arc� and such mappings can be quite �wild��A simpler way to build a logically precise theory of planar graphs is topermit only arcs consisting of a �nite number of straight segments�letus call them polygonal arcs� We can thus call a graph polygonally planarif it can be drawn without edge crossings using polygonal arcs� To provethe Jordan curve theorem for polygonal arcs only is reasonably easy seeExercise �� And it is not too di�cult to verify that any planar graphis polygonally planar too� for this one needs some topology but verylittle� Therefore� allowing for general nonpolygonal arcs achieves noth�ing new in graph drawing�only complications with the Jordan curvetheorem�
�Even a much stronger statement holds� any planar graph can be drawn with�out edge crossings in such a way that every edge is a straight segment� But thisis not an easy theorem�
�� Cycles in planar graphs ���
As was announced earlier� we prefer to rely on intuition at somepoints in deriving results about planar graphs� At the price of longerand more complicated proofs� such imperfections could be removed�and everything could be derived from the Jordan curve theorem andits variations�
Let us begin with a proof of nonplanarity of the graph K�� Lateron� we will prove it again by other means�
����� Proposition� K� is not planar�
Proof� Proceed by contradiction� Let b�� b�� b�� b�� b� be the pointscorresponding to the vertices of K� in some planar drawing� The arcconnecting the points bi and bj will be denoted by �i� j�
Since b�� b�� and b� are vertices of a cycle in the graph K�� thearcs ��� �� ��� �� and ��� � form a Jordan curve k� and hencethe points b� and b� lie either both inside or both outside k� forotherwise the arc ��� � would cross k� First suppose that b� liesinside k� as in the following picture�
b� b�
b�
b�
Then b� lies inside the Jordan curve formed by the arcs ��� ����� �� and ��� �� or in the Jordan curve made up by ��� ����� �� and ��� �� or inside the Jordan curve consisting of ��� ����� �� and ��� ��� In the �rst of these cases� the arc ��� � hasto intersect the Jordan curve formed by the arcs ��� �� ��� �� and��� �� however� and similarly in the remaining two cases�
If the points b� and b� lie both outside k� we proceed quite anal�ogously� �
Faces and cycles in �connected graphs� If e�� � � � � en are theedges of a cycle in a topological planar graph G� then the arcs�e�� � � � � �en form a Jordan curve� By the Jordan curve theorem�we get that each face of G lies either inside or outside this Jordan
We haven�t proved that the interiors of these Jordan curves together coverthe interior of k� and so this is one of the points where we rely on intuitionsomewhat�
��� Drawing graphs in the plane
curve� For brevity� let us call this Jordan curve a cycle of G too �soa cycle of G may now mean either a cycle in the graph�theoreticsense� i�e� a subgraph of G� or the Jordan curve corresponding to agraph�theoretic cycle of G in some drawing of G�
For some topological planar graphs� each face is the interior orthe exterior of some cycle of G� But it need not always be so� For in�stance� a planar drawing of a tree has only one face� Another examplemight look as follows�
F�
F� F�
F�
It turns out that the bad examples are exactly the graphs that arenot ��connected�
����� Proposition� Let G be a ��vertex�connected planar graph�Then every face in any planar drawing of G is a region of some cycle
of G�
Proof� We proceed by induction� making use of Proposition ������characterization of ��connected graphs� If the graph G is a triangle�the statement we are proving follows from the Jordan curve theorem�
Let G � �V�E be a connected topological planar graph withat least � vertices� By Proposition ������ either there exists an edgee � E such that the graph G� � G � e is ��connected� or there area ��connected graph G� � �V �� E� and an edge e � E� such thatG � G�,e� where , denotes the operation of edge subdivision�
Since G is a topological planar graph� G� is a topological planargraph as well� in both cases� Since G� is ��connected� we can use theinductive hypothesis� Each face of the topological graph G� is thus aregion of some cycle of G��
Let us consider the �rst case� where G� � G� e� e � fv� v�g� Thevertices v and v� are connected by the arc �e corresponding to theedge e� and hence they both lie on the boundary of a face F of G��Let kF be the cycle bounding the face F � As the following pictureindicates� the arc �e divides F into two new faces F � and F ���
v
v�
F � F ��
�e����
�� Cycles in planar graphs ���
�This is one of the points where we rely on pictorial intuition andomit a rigorous proof� but see Exercise �� The faces F � and F �� areregions of the cycles � � �e and � � �e� where � and � arethe two arcs connecting v and v� and together forming the cycle kF �Hence the faces of G are all bounded by cycles as claimed� This�nishes the inductive step in the �rst case� where G � G� % e�
The remaining second case is easier� if G � G�,e and each faceof G� is a region of some cycle of G�� then G has the same property�as follows immediately from the de�nition of edge subdivision� Thisconcludes the proof of the proposition� �
Proposition ����� shows that ��connected planar graphs behave� insome sense� more nicely than arbitrary planar graphs� But it turns outthat a still much nicer behavior results by requiring that the consideredplanar graphs be ��vertex�connected� Such graphs have an essentiallyunique planar drawing up to a continuous deformation of the planeand mirror re�ection� and in many ways they are easier to work withsee Section ���� When proving theorems or designing algorithms con�cerning planar graphs� it is usually advisable to deal with ��connectedplanar graphs �rst� and then try to handle the general case by decom�posing a given graph into ��connected pieces� Here we will not pursuethis matter any further�
A combinatorial characterization of planar graphs� Let usremark that the following clearly holds� A graph G is planar if andonly if each subdivision of G is planar� This property can be usedfor a combinatorial characterization of planar graphsa characteri�zation purely in graph�theoretic notions� using no geometric notionsat all� It is the following celebrated result�
����� Theorem �Kuratowski�s theorem�� A graph G is planar
if and only if it has no subgraph isomorphic to a subdivision of K���
or to a subdivision of K��
It is easy to prove one of the implications in this theorem �if G isplanar then it cannot contain a subdivision of a nonplanar graph�but the reverse implication is more demanding and we will not proveit in this book�
This theorem shows that the nonplanarity of any nonplanar graphcan be certi�ed by �nding a subdivision ofK��� orK� in it� From a com�putational point of view� i�e� if we want to really test graph planarityby a computer and perhaps also look for a planar drawing� this methodis not very e�cient� Algorithms are known for testing whether a given
�� Drawing graphs in the plane
graph contains a subdivision of a �xed small graph� but these algo�rithms are fairly complicated and impractical� For planarity testing and�nding �nice� planar drawings� a number of fast although also com�plicated methods have been invented� Such methods can� for instance�test planarity of a given graph on n vertices in time On� Concerning�nice� drawings� it is known that� for example� any planar graph on nvertices can be drawn in such a way that the vertices have integer co�ordinates between � and n and the edges are straight segments� Recentresults in this direction� as well as further references� can be found inKant ����� There are also many interesting problems related to graphdrawing which remain open� For instance� it is not known at the timeof writing this book whether every planar graph has a planar draw�ing where all edges are straight segments with integer lengths� Thisis an example of how easily one can sometimes formulate even di�cultproblems in discrete mathematics�Kuratowski�s theorem characterizes planar graphs by specifying �
�obstacles to planarity�� namely the presence of a subdivision of K�
or of a subdivision of K���� Recently� many theorems in a similar spirithave been found� characterizing various classes of graphs by �nite sets of�obstacles�� The obstacles are usually not forbidden subdivisions of cer�tain graphs but rather so�called forbidden minors see Exercise �������Many outstanding problems in graph theory� including numerous ques�tions about e�cient algorithms� have been solved by this approach andrelated ideas� and currently this area called the structural graph the�ory constitutes one of the most dynamic and successful parts of moderngraph theory� A sample of recent progress in this area is Robertson� Sey�mour� and Thomas ����� where a long�standing open problem has beenresolved by related methods�
Exercises
�� Show that the graph K��� is not planar� in a manner similar to theproof of nonplanarity of K� given in the text�
�� a Find a subdivision of either K��� or K� in the graph on the left inFig� ����
b Is the graph in the middle in Fig� ��� planar�
c Is the graph in Fig� ��� planar�
�� The complete k�partite graph Kn��n������nk has vertex set V �V� +�V� +� � � � +�Vk� where V�� � � � � Vk are disjoint sets with jVij � ni� andeach vertex v � Vi is connected to all vertices of V nVi� i � �� �� � � � � k�Describe all k�tuples n�� n�� � � � � nk of natural numbers� k � �� �� � � ��such that Kn��n������nk is a planar graph�
�� Euler�s formula ���
�� In the proof of Proposition ������ we proceeded by induction� but in�duction on what� There was no explicitly mentioned natural numberas an induction parameter�
�� Prove that if each face of a topological planar graph G is a region ofsome cycle of G then G is ��connected�
�� �Consider an arbitrary drawing not necessarily planar of the com�plete graph Kn� Prove that at least
��
�n�
�pairs of edges have to cross�
Use the nonplanarity of K��
�� The goal of this exercise is to give a rigorous proof� without relying ongeometric intuition�
a �Let k be a Jordan curve consisting of �nitely many segments i�e�a polygon� De�ne two points of R� n k to be equivalent if they canbe connected by a polygonal arc not intersecting k� Prove that thisequivalence has at most two classes�
b �Show that in the situation as in a there are at least two classes�Hint� de�ne an �interior point� as one for which a vertical semilineemanating upwards from it has an odd number of intersections with k�
c Let k be a polygonal Jordan curve as in a� let p� q be two distinctpoints of k� let k�� k� be the two polygonal arcs into which k is dividedby the points p and q� and let r � k�� s � k� be points inside these arcs�Let � be a polygonal arc connecting p and q and lying completely inthe interior of k except for its endpoints� Prove that any polygonalarc connecting r to s and lying in the interior of k except for theendpoints must intersect ��
��� Euler�s formulaThere exists essentially only one basic quantitative formula for planargraphs� One can say that all other results use this formula to someextent� At the same time� it is the oldest formula� It was known to Eulerin ����� and sometimes it is asserted that it was known to Descartes in��� as well� the original statement was about convex polytopes ratherthan about planar graphs�
����� Proposition �Euler�s formula�� Let G � �V�E be a con�
nected planar graph� and let f be the number of faces of some planar
drawing of G� Then we have
jV j � jEj% f � ��
In particular� the number of faces does not depend on the particular
way of drawing�
��� Drawing graphs in the plane
Proof� We proceed by induction on the number of edges of thegraph G� If E � � then jV j � � and f � �� and the formula holds�So let jEj � �� We distinguish two cases�
�� The graph G contains no cycle� Then G is a tree and hencejV j � jEj % �� at the same time we have f � � since a planardrawing of a tree has only one �unbounded face�
�� Some edge e � E is contained in a cycle� In this case the graphG � e is connected� Hence by the inductive hypothesis� Euler�sformula holds for it �we consider the drawing arising from thegiven drawing of G by removing the edge e� The edge e inthe considered drawing of G is adjacent to two distinct facesF and F �� by the Jordan curve theorem� These faces become asingle face after deleting e� Hence both the number of faces andedges increases by � by adding e back to the drawing� and thenumber of vertices is unchanged� hence Euler�s formula is truefor G too�
�
Application� Platonic solids� A Greek school of thinkers associatedwith Plato�s name used to attribute a particular signi�cance to highlyregular geometric solids� the so�called regular polytopes� looking for themeven in the foundations of the structure of the universe� Besides� Ke�pler also regarded as one of his most important discoveries a theory�most likely a mistaken one� according to which the spacing among theplanets� orbits is determined by the geometry of the regular polytopes�A regular polytope is a ��dimensional convex body� bounded by a �nitenumber of faces� All faces should be congruent copies of the same regu�lar convex polygon� and the same number of faces should meet at eachvertex of the body� One reason for the above�mentioned great interestin these objects is most likely their exceptionality� There are only �types of regular polytopes� the regular tetrahedron� the cube� the regu�lar octahedron� the regular dodecahedron� and the regular icosahedronsurely the reader will know which is which�
�Convexity means that whenever x and y are two points of the consideredbody� then the whole segment xy is a part of the body� i�e� the surface has nodips in it�
�� Euler�s formula ���
d � k � � d � �� k � � d � �� k � �
d � �� k � � d � �� k � �
Fig� ��� Graphs of the Platonic solids�
This fact was already known to the ancient Greeks� Let us remark thatif we relax the conditions on regularity a little we do not insist onconvexity� or we allow for two types of faces� etc�� or if we go to higherdimensions� we can meet many more interesting and beautiful geometricshapes� Research in this area is still quite active�Using Euler�s formula� we will show that no other regular polytopes
than the � Platonic ones exist� The actual existence of these regu�lar polytopes must be checked geometrically� which we do not considerhere� The �rst step in proving the non�existence of other regular poly�topes is converting a convex polytope into a planar graph� We place theconsidered polytope inside a sphere� in such a way that the center ofthe sphere lies inside the polytope� Then we project the polytope ontothe sphere imagine that the edges of the polytope are made from wireand we place a tiny lamp in the center� This yields a graph drawn onthe sphere without edge crossings� and as we know from Section ����such a drawing can be metamorphosed into a planar drawing using thestereographic projection� The vertices� edges� and faces of the polytopebecome the vertices� edges� and faces of this planar drawing� respec�tively� This is where the terms �vertex� and �edge� for graphs and�face� for planar graphs come from� For the � regular solids� we thusobtain the graphs in Fig� ����
��� Drawing graphs in the plane
For a regular polytope� the resulting topological planar graph hasthe same degree� d� of each vertex where d �� and each face has thesame number� k �� of vertices on its boundary� The nonexistence ofany other regular polytopes is thus a consequence of the following�
����� Proposition� Let G be a topological planar graph in which eachvertex has degree d and each face is adjacent to k vertices� for someintegers d � and k �� Then G is isomorphic to one of the graphs inFig� ���
Proof� Let us denote the number of vertices of the considered graphG � V�E by n� the number of edges by m� and the number offaces by f � First we use the equation
PvV degGv � �jEj Propo�
sition ������ which in our case specializes to
dn � �m�
Similarly we obtain the equality
�m � kf�
We double�count the number of ordered pairs e� F � where F is a faceof G and e � E is an edge lying on the boundary of F � Each edgecontributes � such pairs as each face is bounded by a cycle� and eachface k pairs�Next� we express both n and f in terms of m using the just derived
equations� and we substitute the results into Euler�s formula�
� � n�m� f ��m
d�m�
�m
k�
By adding m and dividing by �m� we obtain
�
d��
k��
���
m�
Hence if both d and k are known� the other parameters n� m� and fare already determined uniquely� Obviously mind� k � �� for otherwise�d�
�k � �
� � For d � � we get�k � �
��m � � and therefore k � f�� �� �g�
Similarly for k � � we derive d � f�� �� �g� Hence one of the followingpossibilities must occur�
d k n m f� � � � �� � � �� �� � � � ��� � � �� �� � �� � �
Now it is easy to check that in each of these cases the graph is completelydetermined by the values d� k� n�m� f � and it is isomorphic to one of thegraphs in Fig� ���� �
�� Euler�s formula ���
Let us remark that the connection between planar graphs and ��di�mensional convex polytopes is closer than it might seem� As we haveseen� we obtain a planar graph from each convex polytope� A quite di��cult theorem� due to Steinitz� asserts that any vertex ��connected planargraph i�e� a planar graph that remains connected even after deletingany � vertices is the graph of some ��dimensional convex polytope� Adelightful account of the theory of convex polytopes is Ziegler �����
A very important property of planar graphs is that they can onlyhave relatively few edges� a planar graph on n vertices has O�nedges� Here is a precise formulation of this property�
����� Proposition �Planar graph has O�n edges��
�i� Let G � �V�E be a planar graph with at least � vertices� Then
jEj � �jV j��� Moreover� equality holds for any maximal planargraph� that is� a planar graph such that adding any new edge
�while preserving the same vertex set� makes it nonplanar�
�ii� If� moreover� the considered planar graph contains no triangle
�i�e� K� as a subgraph� and has at least � vertices� then jEj ��jV j � ��
�We do not admit graphs with multiple edges in this proposition�
of course��
Proof of �i�� If the graph G is not maximal planar we keep addingedges until it becomes maximal planar� Hence part �i will be provedas soon as we show that jEj � �jV j � � is true for any maximalplanar graph with at least � vertices�
As a �rst step� we want to show that each face �including theouter one of a maximal planar graph with at least � vertices is atriangle�� i�e� it is bounded by a cycle of length ��
If G is disconnected� we can clearly connect its two distinct com�ponents by a new edge� If G is connected but not ��connected� ithas some vertex v whose removal disconnects the graph� creatingcomponents V�� V�� � � � � Vk� k � � �note that we�re using the assump�tion of G having at least � vertices at this moment�� Choose twoedges e and e� connecting v to two distinct components Vi� Vj suchthat e and e� are drawn next to each other� Their endpoints can beconnected by a new edge +e without destroying planarity�
For this reason� a maximal topological planar graph is also called a triangu�
lation�
��� Drawing graphs in the plane
Vi
Vj,e
e
e�
Hence a maximal planar graph with at least � vertices is necessarily��connected� and by Proposition ������ each face is bounded by acycle of the graph� For contradiction� assume that the bounding cycleof some face F contains t � � vertices v�� � � � � vt� If the vertex v� is notconnected by an edge with the vertex v� then we can draw the edgefv�� v�g inside the face F � On the other hand� if fv�� v�g � E�G�this edge must be drawn outside the face F � and therefore fv�� v�gcannot be an edge� for otherwise fv�� v�g and fv�� v�g would have tocross�
v� v�
v�
v�
F
Hence we can safely draw the edge fv�� v�g inside the face F �Thus� each face of a maximal planar graph is a triangle as was
asserted above� From this we get� similar to the proof of Proposi�tion ������ the equality �f � �jEj� where f is the number of faces�Expressing f from Euler�s formula and substituting into the justderived equation� we obtain
jV j � jEj% �
�jEj � ��
The desired equality jEj � �jV j � � follows by a simple algebraicmanipulation� This proves part �i�
Proof of �ii�� We proceed likewise� After adding some edges if nec�essary� we may suppose that our graph is an edge�maximal triangle�free planar graph� meaning that by adding any new edge we createa triangle or make the graph nonplanar �or both� We can againassume that the graph is connected�
If G is not �vertex ��connected then it has a vertex v whosedeletion splitsG into components V�� � � � � Vk� k � �� Certainly we canadd some edge going between distinct components in such a way thatG remains planar� but for some edges we could introduce a triangle
�� Euler�s formula ���
�this happens in case we connect two vertices both adjacent to v�and so we have to proceed more carefully� If each of the componentsVi consists of a single vertex then G is a tree and the formula beingproved holds for it� So let us suppose jV�j � �� and consider a faceF having both a vertex of V� and a vertex of some other Vi on itsboundary� as in the picture�
v v�
v�
Vi
V�
The component V� must have at least one edge� fv�� v�g� on theboundary of F � and since G has no triangle� it is not possible thatboth v� and v� are adjacent to v� Hence v� or v� can be connectedto a vertex of Vi within F without possibly creating a triangle�
Therefore� we may assume that G is ��connected� In this case�each face is bounded by a cycle in G� Each such cycle has length atleast �� and by double�counting we get �jEj � �f this time� UsingEuler�s formula we �nally arrive at jEj � �jV j � �� �
A typical wrong proof� Suppose we want to prove that any topo�logical planar graph with n � vertices such that each face is boundedby � edges has �n � � edges� Students sometimes give an incorrectanswer of the following type� We proceed by induction on n� For n � �we have a single triangle with � edges and � vertices� so the claim holds�Next� let us assume the statement holds for any topological planar graphG with n vertices� For any such G� we add a vertex into some face andconnect it to the � vertices of that face as in the following picture�
�
This yields a graph G� with n � � vertices� The number of edges of Gis �n � � by the inductive hypothesis� and we have added � new edges�Hence G� has �n � � � � edges and the statement holds for graphswith n � � vertices as well� Well� the problem is that not all possibletopological planar graphs G� on n�� vertices with triangular faces canarise from some G by the operation described� For instance� the graphof the regular octahedron drawn in Fig� ��� has all degrees �� while
��� Drawing graphs in the plane
any graph produced from a smaller graph by the operation has at leastone vertex of degree ��
Part �i of Proposition ����� has an important and often appliedconsequence� namely that every planar graph has some vertex ofdegree at most �� Similarly part �ii guarantees that a planar graphwithout triangles contains a vertex of degree no more than ��
Part �i also shows that K� is not planar� because it has �� edges�while a planar graph on � vertices has at most � edges� Similarly�ii implies the nonplanarity of K���� since a triangle�free graph on �vertices has at most � edges�
We prove yet another proposition� giving us more information aboutpossible scores of planar graphs�
����� Proposition� Let G � V�E be a �connected planar graphwith at least � vertices� Let ni be the number of its vertices of degree i� and let fi be the number of faces �in some xed planar drawing�bounded by cycles of length i� Then we haveX
i��
�� ini � �� � �Xj��
j � �fj �
or� rewritten di�erently�
�n���n���n���n��n��n ��n��� � � � ����f���f���f� � � � �Hence �n���n���n���n��n� ��� and so every planar graph withat least � vertices contains at least � vertices of degree no larger than ��
Proof� Clearly jV j �Pi ni� f �
Pi fi� By substituting for jV j and f
from these equations into Euler�s formula we have
�jEj � �jV j� f � � �Xi
�ni �Xj
�fj � �� ���
By a double�counting similar to that in previous proofs we obtain fur�ther relations�
Pi ini � �jEj �
Pj jfj � By expressing �jEj using ����
these equalities are transformed intoXj
j � �fj � � �Xi
�niXj
�fj �Xi
i� �ni � ��
We multiply the �rst of these equalities by � and we subtract the secondone from it� The result isX
i
�� ini � � � �Xj
j � �fj � ��
This already gives the proposition� �
�� Euler�s formula ���
Exercises
�� Prove that the bound jEj � �jV j � � for triangle�free planar graphs isthe best possible in general� That is� for in�nitely many n constructexamples of triangle�free planar graphs with n vertices and �n � �edges�
�� a Show that a topological planar graph with n � vertices has atmost �n� � faces�b Show that a topological planar graph without triangles has at mostn� � faces�
�� Prove that a planar graph in which each vertex has degree at least �must have at least �� vertices�
�� For which values of k can you prove the following statement� Thereexists an n� such that any planar graph on at least n� vertices containsat least k vertices of degree at most � Could it hold for every k�
�� �Consider a maximal triangle�free planar graph G � V�E� i�e� atriangle�free planar graph such that any graph of the form G � e�where e � �
V�
�nE� contains a triangle or is nonplanar� Prove that eachface in any drawing of such a graph is a quadrilateral or a pentagon�
�� Find an example� other than the Platonic solids� of a convex polytopein the ��dimensional space such that all faces are congruent copies ofthe same regular convex polygon� �Can you list all possible examples�
�� Game �Sprouts� The following game has been invented by J� H�Conway and M� S� Paterson� Initially� n dots are drawn on a sheetof paper the game is already interesting for small n� say for n � ��The players alternate their moves� and the player with no legal moveleft loses� In each move� a player connects two dots with an arc anddraws a new dot somewhere on the newly drawn arc� A dot can beused as an endpoint of a new arc only if there are at most � other arcends leading into that dot� and a new arc must not cross any otherarcs already drawn� So at each moment we have a planar drawing ofa graph with maximum degree at most �� the dot on the newly addedarc initially has degree �� An example�
� � � �
a Prove that a game with n initial dots lasts no more than �n � �moves for any strategy of the players�
b �Prove that a game with n initial dots lasts at least �n moves forany strategy of the players�
�� Drawing graphs in the plane
c ��Brussels sprouts� We modify the game as follows� Instead ofdots we draw little crosses� and the ends of new arcs are connected tothe arms of the crosses thus� the vertices can have maximum degree� this time� On each new arc� a new cross is drawn by crossing thearc with a short segment� as in the following example�
� � � �
� � � �
Prove that this game always has exactly �n � � moves and so it iseasy to determine who wins�
�� Consider a set L consisting of n lines in the plane� No two of them areparallel but many can pass through a single point� By drawing theselines we create vertices intersection points of the lines� edges parts ofthe lines between intersections and semiin�nite rays extending from the�rst and last intersections on a line to in�nity� and faces connectedparts of the plane after removing the lines from it�
a �Express the number of edges in terms of the number of verticesand faces�
b Prove that unless all the lines pass through a single point� thereexist at most n faces bounded by � semiin�nite edges�
c �Prove that unless all lines pass through a single point� there existsat least one intersection with only � lines passing through it� This isthe famous Sylvester�s problem�
�� ��Consider an arbitrary topological planar graph� Suppose that everyedge has one of the two colors red� blue� Show that there exists a vertexof the following type�
blue edges red edges
red edges form a contiguous segment when going around the vertex�and similarly for blue edges� one of the two groups can be empty�
�� Coloring maps� the fourcolor problem ���
Fig� ��� An example of a map for the four�color problem�
��� Coloring maps� the four�color problem
Consider a political map showing the boundaries of states as inFig� ���� Suppose that each state is a connected region �that�s why wehaven�t drawn islands like Britain� Ireland� Sardinia� Sicily� Corsica�etc�� on our schematic map� and we also had to leave out Russiaadisconnected state in AD ������ We consider two regions neighborsif they have at least a small piece of border in common� so it is notsu�cient if the boundaries touch in one or several points �but suchsituations are very rare on maps anyway� We want to color eachstate in such a map by some color� and no two neighboring statesshould get the same color� as is usual on political maps� What is theminimum necessary number of colors� For the map shown� � colorsare su�cient �try �nding such a coloring��
Here is one of most celebrated combinatorial problems�
����� Problem �Fourcolor problem�� Can each planar map becolored by at most � colors�
��� Drawing graphs in the plane
Four is certainly the minimum number of colors coming into con�sideration for coloring all planar maps� This is illustrated by themap shown above �consider Austria or Luxembourg� say or by thefollowing examples�
Here we prove that any planar map can be colored by � colors� Al�though this result has been known for more than ��� years� the four�color problem was only solved �positively in the late ����s� Knownproofs of the fact that any planar map can be colored by � colors aredi�cult and they substantially depend on analyzing a large numberof cases by computer� So far no one has managed to do the proofby hand� although the original proof was greatly simpli�ed in �����Robertson et al� ����� But some basic ideas of these complicatedproofs appear in two proofs of the ��ve�color theorem� given below�
The four�color problem looks like a geometric question� but it canbe reformulated in a purely combinatorial manner� Coloring regionsof a map can be translated to coloring vertices of a planar graph�First we de�ne the notion of coloring for an arbitrary graph�
����� De�nition �Chromatic number of a graph�� Let G ��V�E be a graph� and let k be a natural number� A mapping c�V �f�� �� � � � � kg is called a coloring of the graph�� G if c�x � c�y holdsfor every edge fx� yg � E� The chromatic number of G� denoted by��G� is the minimum k such that there exists a coloring c�V �G�f�� �� � � � � kg�
The chromatic number of a graph belongs among the most im�portant combinatorial notions� However� in this book we mention itonly in this section�
Mathematically� a map can be regarded as a drawing of a planargraph� The states on the map are faces of the graph� the vertices of
��Sometimes this is called a proper coloring of G�
�� Coloring maps� the fourcolor problem ���
the graph are the points lying on borders of � or more states� and theedges of the graph are the portions of the borders between vertices�
Note that multiple edges may arise in the graph corresponding to amap�
In order to convert the map�coloring problem �i�e� coloring thefaces of a topological planar graph to a problem of coloring graphvertices in the sense of the de�nition just given� we introduce thenotion of the so�called dual graph� Imagine that we mark the capitalcity of each state in the considered map by a dot� and that thecapitals of each two neighboring states are connected by a highwaylying in the territory of these two states and crossing their commonboundary� The vertices of the dual graph are the capitals and theedges are the highways�
For de�ning the dual graph formally� we need also multiple edgesand loops� so let us recall one possible way of introducing them� Agraph with multiple edges and loops can be represented as a triple�V�E� �� where V and E are disjoint sets and ��E � �V
�
� � V is amapping assigning to each edge its two endpoints and to each loopits single endpoint �see Section ��� for a more detailed discussion�Now we can give a mathematical de�nition of the dual graph�
����� De�nition �Dual graph�� Let G be a topological planar
graph� i�e� a planar graph �V�E with a �xed planar drawing� Let
F denote the set of faces of G� We de�ne a graph� possibly with
loops and multiple edges� of the form �F � E� �� where � is de�ned by��e � fFi� Fjg whenever the edge e is a common boundary of the
faces Fi and Fj �we also permit Fi � Fj � in the case when the same
face lies on both sides of a given edge�� This graph �F � E� � is calledthe �geometric dual of G� and it is denoted by G��
��� Drawing graphs in the plane
An example�
G G�
The dual graph G� can be drawn together with the drawing of thegraph G� as was already suggested in the above informal explanationwith capitals and highways� We choose a point bF inside each faceF of G� and for each edge e of G we draw an arc crossing e andconnecting the points bF and bF � � where F and F � are the facesadjacent to the edge e� This arc lies completely in the faces F and F ��In this way� we obtain a planar drawing of G��
This way of drawing the dual graph witnesses its planarity� Furtherexamples of dual graphs can be found in Fig� ���� The graphs of thecube and of the regular octahedron are dual to each other� similarlythe graphs of the regular dodecahedron and icosahedron are mutuallydual� and �nally the graph of the tetrahedron �i�e� K� is dual toitself�
Consider a planar map� and regard it as a drawing of a planargraph G in the manner indicated above� The colorability of this mapby k colors is then equivalent to the colorability of the vertices ofthe dual graph G� by k colors�
On the other hand� any planar graph can be obtained as a sub�graph of a suitable dual graph� We indicate a proof by a picture only�for example� the graph
�� Coloring maps� the fourcolor problem ���
is contained in the dual of
�Alternatively� one can argue that any topological planar graph isisomorphic to the dual of its dual� Hence problems of map colorabil�ity can be reformulated as problems concerning the colorability ofplanar graphs� In particular� we can rephrase�
����� Problem �Fourcolor problem again�� Does ��G � �hold for every planar graph G�
We prove a weaker result�
����� Proposition �Fivecolor theorem�� Any planar graph Gsatis�es ��G � ��
First proof� We proceed by induction on the number of vertices ofthe graph G � �V�E� For jV j � �� the statement holds trivially�
By the results of Section ��� we know that any planar graph hasa vertex v of degree at most �� If we even have degG�v � � thenconsider the graph G� v� and apply the inductive hypothesis on it�Assuming that the graph G � v is colored by colors ����� � � ��� thenwe color the vertex v by some color i � f�� �� � � � � �g not occurringamong the �at most � colors used on the neighbors of v� In this way�we get a coloring of G by � colors�
A very similar argument already shows that the chromatic numberof every planar graph is at most �� so in the rest of the proof we workon improving this � to ��
��� Drawing graphs in the plane
Also� it may be instructive to formulate an algorithm for coloringevery planar graph by at most � colors or� with the improvement below�by at most � colors based on this proof� Note that such an algorithmcolors the low�degree vertex v last� after all other vertices have beencolored�
It remains to investigate the case when degG�v � �� Let us con�sider the graph G with some �xed planar drawing� and let t� u� x�z� y be the vertices connected to v by an edge� listed in the orderthe corresponding edges emanate from the vertex v �in the clockwisedirection� say�
x
u
ty
z
Let us again consider a coloring c�V �G � v � f�� �� � � � � �g ofthe graph G�v by � colors guaranteed by the inductive assumption�If at most � colors occur at the neighbors of v then the vertex vcan be assigned a color distinct from the colors of all its neighbors�Thus� we suppose that the neighbors of v have all the � distinctcolors� Consider the vertices x and y� and de�ne Vx�y as the set ofall vertices of the graph G� v having color c�x or c�y� Clearly x�y � Vx�y� It may be that there exists a path from x to y in the graphG� v using only the vertices of the set Vx�y� or such a path need notexist� We distinguish these two cases�
�� No such path exists� Let V �x�y be the set of all the vertices s �
V �G � v that can be reached from x by a path using only thevertices from Vx�y� In particular� we have y � V �
x�y� We de�ne anew coloring c� of the graph G� v�
c��s �
�����c�s if s �� V �
x�y
c�y if s � V �x�y and c�s � c�x
c�x if s � V �x�y and c�s � c�y
�this means that we exchange the colors on the set V �x�y� It
is easy to see that c� is a coloring of G � v again� and sincec��x � c��y � c�y� we can set c��v � c�x� obtaining a validcoloring of G by � colors in this way�
�� Coloring maps� the fourcolor problem ���
�� Next� suppose that there exists a path P from x to y with allvertices in Vx�y� In this case� we consider the pair of vertices tand z and we de�ne a set Vt�z as the set of vertices of G � vcolored by the colors c�t and c�z� The sets Vx�y and Vt�z aredisjoint� The drawing of the path P forms� together with theedges fv� xg and fv� yg� a cycle�
xu
t
y
z
P Vx�y
V �z�t
Vz�tv
One of the points z� t lies inside this cycle and the other oneoutside� and hence any path from z to t has to use some vertexof the cycle� Hence there is no path from z to t only using verticesof the set Vz�t� and so we can construct a coloring of G by � colorsin the same way as in case �� only with z and t in the role of xand y�
This �nishes the �rst proof of the �ve�color theorem� �
Edge contraction� Before commencing a second proof� let us in�troduce one more important graph operation� Let G � �V�E be agraph �not necessarily planar at this moment and let e � E be oneof its edges� The contraction of e means that we �glue together� bothvertices of e into a single new vertex� and then we remove multipleedges that may have arisen by this gluing� The resulting graph isdenoted by G�e� and formally it is de�ned as follows�
G�e � �V �� E��
where e � fx� yg and
V � � �V n fx� yg � fzgE� � fe � E� e fx� yg � �g
�ffz� tg� t � V n fx� yg� ft� xg � E or ft� yg � Eg�here z � V denotes a new vertex�
Lemma� If G is a planar graph and e � E�G is an edge then the
graph G�e is planar as well�
��� Drawing graphs in the plane
Informal proof� By a picture�
��e
xy z
�
Second proof of Proposition ������ We again work by inductionon the number of vertices of the considered planar graph G � �V�E�We begin as in the �rst proof� So we may assume that G � �V�E is aplanar graph with at least � vertices in which each vertex has degreeat least �� Let us choose a vertex v of degree �� Since the graph Gis planar� it contains no K� as a subgraph� and hence there existsa pair of neighbors of v not connected by an edge� Let us denotethe vertices in some such pair by x and y� and let t� u� and z bethe remaining � neighbors� We look at the graph G� produced fromG by contracting the edges fx� vg and fy� vg �i�e� the triple x� y� vof vertices is replaced by a single new vertex w� this generalizes thede�nition of contraction of a single edge in an obvious manner� Thisgraph is planar and has fewer vertices than G� Hence some coloring c�
of G� by � colors exists by the inductive hypothesis� In this situation�we de�ne a coloring c of the graph G as follows�
c�s �
�����c��s if s � fx� y� vgc��w if s � x or s � yi � f�� � � � � �g n fc��w� c��u� c��t� c��zg if s � v�
The picture below illustrates this de�nition�
w
� �
�
��� w
��
�
�� �
situation in G� situation in G
It is not di�cult to check that the c thus de�ned is a valid coloringof the graph G� �
Yet another proof is outlined in Exercise ���
�� Coloring maps� the fourcolor problem ���
Let us remark that the question of colorability can also be studiedfor graphs that can be drawn on other types of surfaces� This questionis completely solved by now� the maximum possible chromatic numberof a graph of genus k equals�
� �p� � ��k
�
�
It is remarkable that the case of genus � i�e� of planar graphs� is by farthe most di�cult one� For larger genus� this result Heawood�s formulawas proved much earlier than the four�color theorem�
Exercises
�� Prove that �G � � � maxfdegGx� x � V g holds for every �nitegraph G � V�E�
�� For a graph G� put G � minfdegGv� v � V g the minimum degreeof G� Prove �G � � � maxfG�� G� � Gg� where G� � G meansthat G� is a subgraph of G�
�� �Call a graph G outerplanar if a drawing of G exists in which theboundary of one of the faces contains all the vertices of G we canalways assume the outer face has this property� Prove that everyouterplanar graph has chromatic number at most ��
�� Let G be a planar graph containing no K� as a subgraph� Prove�G � �� A di�cult theorem due to Gr&otsch asserts that� actually��G � � holds for all planar triangle�free graphs�
�� CS Based on one of the proofs of the �ve�color theorem� design analgorithm for coloring a given planar graph by at most � colors� Assumethat a planar drawing of the graph is given in the following form� foreach vertex of G� we have a circular list of the neighbors of v� listed inthe order of the corresponding outgoing edges in the drawing�
�� CS
a Consider a greedy algorithm for graph coloring� Pick one of the yetuncolored vertices arbitrarily and color it with the smallest color thecolors are natural numbers �� �� � � � not used on any of its already col�ored neighbors� For each number K� �nd a graph G having a coloringby � colors i�e� bipartite but such that the algorithm just describedsometimes colors G by at least K colors�
b Can you �nd a planar G as the example in a�
c The algorithm can be made more sophisticated as follows� amongthe yet uncolored vertices� pick one with the largest degree� and colorit as in a� Show that graphs G as in a still exist�
� Drawing graphs in the plane
d This can be continued as a game� Participants propose versions ofthe greedy algorithm for graph coloring� and others try to �nd graphsfor which the algorithm performs badly�
Remark� It is known that no polynomial�time algorithm can do ap�proximate coloring very well� for instance to color all ��colorable graphson n vertices by at most K colors for some constant K� unless poly�nomial�time algorithms for exact coloring and many other di�cultproblems exist� which is considered very unlikely�
�� Consider a map M where each state has at most k connected regionsa more realistic model of the world situation� Using Exercise �� showthat the chromatic number of every such map is no larger than �k foreach state� we insist that all its regions be colored by the same color�
�� The following picture is an example of a map where each state has �regions�
� �
�
�
�
� �
�
�
�
� �
��
� �
�
� �
�
Prove that the chromatic number of this map is ���
�� Prove that each graph G has at least���G��
�edges�
� � a �Consider a planar graph G with all degrees even� Prove that themap arising from any planar drawing of G can be colored by � colors�
b �Using a� prove that there exists no topological planar graphwith all degrees even such that all the inner faces are triangles i�e�bounded by cycles of length � and the outer face is a pentagon�
��� �Let us say that a graph H is a minor of a graph G if a graph iso�morphic to H can be obtained from G by a repeated application ofthe following operations� deleting an edge� deleting an isolated vertex�contracting an edge� Deduce the following result from Kuratowski�s
�� Coloring maps� the fourcolor problem ��
theorem� A graph G is planar if and only if neither K� nor K��� is aminor of G�
��� List chromatic number Let G � V�E be a graph� and supposethat a �nite list Lv of natural numbers is given for each vertex v � V �A mapping c�V � N is called a list coloring with respect to the givenlists Lv� v � V if cv � Lv holds for all v � V and cv �� cv�whenever fv� v�g � E� The list chromatic number of G� denoted by��G� is the smallest number k such that G has a list coloring for anycollection of lists Lv with jLvj � k for all v � V �
a Find an example of a graph with ��G � �G�
b �For each integer k� construct a bipartite graph G with ��G � k�
Remark� There exists a planar graph G with ��G � ��
��� �The notion of list coloring from the previous exercise is used in a shortand remarkable proof of the �ve�color theorem ����� due to Thomassen�To reconstruct that proof� establish the following statement by induc�tion on the number of vertices�
Let G � V�E be a topological planar graph and let Lv� v � V � belists with the following properties�
� The boundary of the unbounded face is a cycle C with verticesv�� v�� � � � � vk numbered along the circumference�
� All bounded faces are triangles�� Lv� � f�g� Lv� � f�g�� jLvij � � for i � �� �� � � � � k�� jLvj � � for all vertices distinct from the vi i�e� lying in theinterior of the bounding cycle C�
Then G has a list coloring with respect to the lists Lv�
This proof uses neither Euler�s formula nor the existence of a low�degree vertex� and it is an example of mathematical induction parexcellence�
�
Double�counting
In pre�computer ages� double�counting was used by accountants�When adding up the numbers in a table� they �rst found the sum ofthe row totals and then they compared it to the sum of the columntotals� If their computation was correct� both results were the same�Put mathematically� if A is an nm matrix then
nXi��
mXj��
aij �mXj��
nXi��
aij�
Pictorially�
�
In other words� the order of summation in a double sum like this maybe changed� This simple idea underlies many mathematical tricksand proofs� in more complex cases it is accompanied by other ideas�of course� The main di�culty is usually in �guring out what exactlyshould be double�counted�
��� Parity arguments
In Section ���� we encountered the handshake lemma� Any graph
has an even number of odd�degree vertices� The proof was in facta typical double�counting �we double�counted �ends of edges�� Us�ing this claim� we were able to exclude some vectors as possiblegraph scoresfor instance� the vector ��� �� �� �� �� But there aremuch more interesting ways to use the handshake lemma� For in�stance� we can sometimes prove the existence of a certain object� Tothis end� we reformulate the claim slightly� If we know that a graph
G has at least one vertex of an odd degree� then it must have at least
two such vertices� Next� we demonstrate a nice application�
��� Parity arguments ��
Let us draw a big triangle in the plane with vertices A�� A�� A��We divide it arbitrarily into a �nite number of smaller triangles� asin the following picture�
A� A�
A�
�
�
�
�
�
�
�
� � �
��
��
�
�
�
No triangle may have a vertex inside an edge of any other small tri�angle� so that if we consider the resulting picture as a drawing of aplanar graph� all inner faces are triangular� Let us assign the labels�� �� � to the vertices of the big and the small triangles� under thefollowing rules� the vertex Ai gets the label i� i � �� �� �� and all ver�tices lying on the edge AiAj of the big triangle may be assigned onlythe label i or j� Otherwise the assignment is completely arbitrary�
����� Proposition �Sperner�s lemma�a planar version�� In
the situation described above� a small triangle always exists whose
vertices are assigned all the three labels �� �� ��
Proof� We de�ne an auxiliary graph G� see Fig� ���� Its verticesare the faces of our triangulation� i�e� all small triangles plus theouter face� In the �gure� the vertices are depicted as little blacktriangles inside the corresponding faces� The vertex for the outer faceis denoted by v� Two vertices� i�e� faces of the original drawing� arejoined by an edge inG if they are neighboring faces and the endpointsof their common edge have labels � and �� This also concerns theouter face vertex v� it is connected to all small triangles adjacent tothe circumference of the big triangle by a side labeled ���
A small triangle can be connected to some of its neighbors inthis graph G only if one of its vertices is labeled by � and anotherby �� If the remaining vertex is labeled � or �� the considered small
�� Doublecounting
A� A�
A�
�
�
�
�
�
�
�
� � �
��
��
�
� v
�
Fig� ��� Illustration for the proof of Sperner�s lemma�
triangle is adjacent to exactly two of its neighbors� If the remainingvertex has label �� then the considered triangle is adjacent to exactlyone neighbor� and this is the only case where the degree of a small
triangle in the graph G is odd� We now show that the vertex v �theouter face has an odd degree in G� Then� by the handshake lemma�there exists at least one other vertex of odd degree in G� and this isthe desired small triangle labeled �� �� ��
The edges of the graph G incident to v can obviously only crossthe side A�A� of the big triangle� By the rules of the labeling� thisside only contains vertices labeled by � or �� Let us write downthe sequence of these labels� starting at A� and ending at A�� Thenumber of neighbors of v is just the number of alterations between �and � in this sequence �the number of times a segment of ��s ends anda segment of ��s starts or the other way round� Since the sequencebegins with � and ends with �� the number of such alterations mustbe odd� Hence v has an odd degree in G� �
Sperner�s lemma is not a toy problem only� it is a crucial step in theproof of a famous theorem� Before we state this theorem� let us mentiona simpler theorem of a similar kind as a warm�up�
����� Proposition One�dimensional �xed point theorem� Forany continuous function f � � � ��� � � ��� there exists a point x � � � ��such that fx � x�
Such an x is called a �xed point of the function f � The propositioncan be proved by considering the function gx � fx � x� This is a
��� Parity arguments ��
continuous function with g and g� � � Intuitively it is quiteclear that the graph of such a continuous function cannot jump acrossthe x�axis and therefore it has to intersect it� and hence g is at somepoint of � � ��� Proving the existence of such a point rigorously requiresquite some work� In analysis� this result appears under the heading�Darboux theorem��Fixed point theorems generally state that� under certain circum�
stances� some function f must have a �xed point� i�e� there exists an xsuch that fx � x� Such theorems belong to the key results in manyareas of mathematics� They often serve as a tool for proving the exis�tence of solutions to equations of various types di�erential equations�integral equations� etc�� They even play a role in the theory of themeaning of computer programs� the so�called program semantics�In Brouwer�s �xed point theorem� the ��dimensional interval from
Proposition ����� is replaced by a triangle in the plane� or by a tetrahe�dron in the ��dimensional space� or by their analogs in higher dimensionssimplices� Here we prove only the ��dimensional version since we haveonly proved Sperner�s lemma in � dimensions but see Exercise �� Theproof belongs more to mathematical analysis� However� we will try topresent it using a minimum of facts and notions from analysis� and wewill recall the necessary facts as we go along�Let - denote a triangle in the plane� For simplicity� let us take the
triangle with vertices A� � �� � A� � � �� and A� � � �
A� � � A� � ��
A� � � �
A function f � - � - is called continuous if for every a � - and forevery � � there exists � such that if b � - is a point at distanceat most from a then the distance of fa and fb is at most �� Brie�y�f maps close points to close points�
����� Theorem Planar Brouwer�s �xed point theorem� Everycontinuous function f � -� - has a xed point�
Proof� We de�ne three auxiliary real�valued functions ��� ��� and ��on the triangle -� For a point a � - with coordinates x� y� we set
��a � x� ��a � y� ��a � �� x� y�
Geometrically� the �i are as in the following illustration�
�� Doublecounting
A� A�
A�
a
�p����a�
���a����a�
The key properties of these functions are� �ia and ��a���a���a � � for all a � -�Further we de�ne sets M��M��M� � -�
Mi � fa � -� �ia �ifag�
i � �� �� �� Thus� Mi consists of the points that are not moved fartherapart from the side opposite to Ai by the function f �Note that every point p � M� �M� � M� is a �xed point of the
function f � for if p is not �xed then f must move it away from some ofthe sides� In more detail� if p � M� �M� �M� then we have �ip �ifp for all i � �� �� �� and since
Pi �ip �
Pi �ifp � � we get
�ip � �ifp for all i� which implies p � fp� Our goal now is to�nd a point in the intersection M� �M� �M��Consider a sequence of successively re�ning triangulations of the
triangle -�
� � �
In each of these triangulations� we label all vertices of the triangles by�� �� or �� We require that a vertex labeled i belongs to the setMi� and�moreover� that the assignment satis�es the rules of Sperner�s lemma�We have to make sure this can always be arranged�The vertex A� has the largest possible distance from its opposite
side� hence this distance cannot increase under f � Therefore A� � M�
and we can label A� by �� similarly for A� and A�� A point a lying onthe side A�A� has ��a � ��a � �� which implies that fa cannotsatisfy both ��fa � ��a and ��fa � ��a� Thus a �M��M��and so we can label all vertices on the side A�A� only by ��s and ��s�A similar argument works for the other sides� Finally� each point of -belongs to at least one of the sets Mi since it cannot be moved fartherfrom all three sides at once� This time we leave a detailed veri�cationto the reader�
��� Parity arguments ��
Now Sperner�s lemma ����� implies that each of the successivelyre�ning triangulations has a triangle labeled �� �� �� Let us denote thevertices of some such triangle in the jth triangulation by aj��� aj��� andaj�� in such a way that aj�i belongs to Mi for i � �� �� ��Consider the in�nite sequence of points a���� a���� a���� � � �� We need
to choose an in�nite convergent subsequence from it� This is always pos�sible� in fact� any in�nite sequence of points inside the triangle contains aconvergent in�nite subsequence� This property of the triangle�shared�for instance� by any closed and bounded subset of the plane�is calledthe compactness� So suppose that we have chosen a convergent subse�quence aj���� aj���� aj���� � � �� j� � j� � j� � � � �� and let us denote itslimit point by p�We claim that p � M�� Indeed� by the de�nition of M�� we have
��ajk�� ��fajk�� for all jk� and taking a limit on both sides yields��p ��fp� because taking a limit preserves nonstrict inequalitiesbetween continuous functions�Since the diameter of triangles in the successive triangulations tends
to � the sequences of the other vertices� i�e� aj���� aj���� aj���� � � � andaj���� aj���� aj���� � � �� also converge to the point p� This implies thatp � M� and p � M� as well� Thus p is the desired �xed point of thefunction f � �
A number of more complicated results similar to Brouwer�s �xedpoint theorem are known� For example� under any continuous mappingof the surface of a ��dimensional ball to the plane� some two points atopposite ends of a diameter of the ball are mapped to the same pointthe so�called Borsuk$Ulam theorem� Such theorems are proved in abranch of mathematics called algebraic topology� The proofs typicallyemploy fairly complex techniques� but deep down they are often basedon parity arguments similar to Sperner�s lemma�
Let us present another example illustrating the use of the hand�shake lemma� We will analyze a game similar to the game calledHEX� It takes place on a board like the one shown in Fig� ��� �butthe triangulation inside the outer square may be arbitrary� Theplayers take turns� Each player in turn marks an unmarked nodewith her symbol� For example� the �rst player �Alice paints nodesgray and the second player �Betty black �boring colors but we canillustrate them in a black�and�white book� In the starting position�Alice has the nodes a and c marked� and Betty has b and d� Alicewins if she manages to mark all nodes of a path from a to c� andBetty�s goal is a path from b to d� If a player is supposed to make amove and has no more nodes to mark� the game ends in a draw�
�� Doublecounting
a b
cd
Fig� ��� A game board�
����� Proposition� On a board of the given type �the outer face is
a square� all inner faces are triangles�� a draw is impossible�
Proof� Assume for contradiction that a draw has occurred� Let Abe the set of nodes marked by Alice and let B be the set of nodesmarked by Betty�
Let us assign labels �� �� � to nodes according to the followingrules� A node in A is labeled by � if it can be connected to a by apath with all vertices belonging to A� Similarly� nodes in B connectedto b by a path lying entirely in B are labeled by �� The remainingnodes get label �� By the hypothesis� both c and d are labeled by ��otherwise one of the players would have won�
��� Parity arguments ��
We will show that there is an inner triangular face T labeled ���� �� This leads to a contradiction� since the node of T labeled � �callit x can belong neither to A nor to B� Indeed� if x belongs to A�we consider the node y of the triangle T labeled by �� By de�nitionof the labeling� there is a path from a to y using only nodes of A�and this path could be extended to x� since y is adjacent to x� Fora similar reason x does not belong to B� which is a contradiction�This reasoning is illustrated by the following picture�
a b
�
��
�� �
�
��
�
How do we prove the existence of a triangle labeled �� �� �� Ex�actly like Sperner�s lemma� We leave it to the reader� Another verysimilar proposition is presented in Exercise �� �
Let us remark that this proof makes substantial use of the factthat all inner faces of the board are triangular and the outer face hasjust the � vertices a� b� c� d� If we allow� for instance� quadrilateralinner faces� the game might possibly end in a draw�
Various games from a mathematical point of view are investigatedin the interesting book by Berlekamp� Conway� and Guy �����
Exercises
�� Consider a drawing of a planar graph all of whose faces� includingthe outer one� are triangular i�e� have � vertices� To each vertex weassign� quite arbitrarily� one of the labels �� �� �� Prove that there arean even number of faces whose vertices get all � labels�
�� A well�known problem about a tourist climbing a mountain also re�lates to �xed points� A tourist starts climbing a mountain at � in themorning� He reaches the summit at �pm and spends the night therein a shelter built there especially for that purpose� At � the nextmorning he starts descending along the same trail� He often pauses tocontemplate the view� and so he reaches the starting point at � in theevening again� Prove that there is a place on the trail that he passedthrough at the same time on both days�
�� A building engineer is standing in a freshly �nished apartment andholding a �oor plan of the same apartment� Prove that some point in
�� Doublecounting
the plan is positioned exactly above the point on the apartment�s �oorit corresponds to�
�� Decide for which of the various sets X listed below is an analog ofBrouwer�s �xed point theorem ����� valid i�e� every continuous func�tion f �X � X has a �xed point� If it is valid� derive it from Theo�rem ������ and if not� describe a function f witnessing it�
a X is a circle in the plane we mean the curve� not the disk boundedby it�
b X is a circular disk in the plane�
c X is a triangle in the plane with one interior point removed�
d X is a sphere in the ��dimensional space a surface�
e X is a sphere in the ��dimensional space with a small circular holepunctured in it�
f X is the torus see Section ����
g X is the Klein bottle see Section ����
�� Sperner�s lemma in dimension �
a �Consider a tetrahedron T � A�A�A�A� in the ��dimensional spaceand some subdivision of T into small tetrahedra� such that each faceof each small tetrahedron either lies on a face of the big tetrahedron oris also a face of another small tetrahedron� Let us label the vertices ofthe small tetrahedra by labels �� �� �� �� in such a way that the vertexAi gets i� the edge AiAj only contains vertices labeled i and j� andthe face AiAjAk has only labels i� j� and k� Prove that there exists asmall tetrahedron labeled �� �� �� ��
b Formulate and prove a ��dimensional version of Brouwer�s �xedpoint theorem about continuous mappings of a tetrahedron into it�self�
�� Consider a game as in Proposition ������
a Prove that on any board meeting the condition of Proposition ������either Alice or Betty has a winning strategy i�e� if she does not makea mistake she wins� regardless of how the other player plays�
b Find an example of a game board meeting the condition againsuch that Betty has a winning strategy�
c �Show that if the board is symmetric with respect to rotation by� degrees about the center i�e� if it looks the same from both players�points of view� then Alice always has a winning strategy�
�� The real game HEX� as the reader might know� was invented by PietHein and it is played on a board like this�
��� Sperner�s theorem on independent systems ���
Alice�s side
Betty�s side
Alice�s side
Betty�s side
Alice�s goal is to connect her two sides by a contiguous chain of �eldsoccupied by her pieces� and Betty wants to connect her sides�
a Discover and explain the connection of this game to the versiondiscussed in the text�
b Having no HEX game board at hand� Alice and Betty startedplaying HEX on an ordinary chessboard� Alice tried to connect twoopposite sides and Betty the other two sides� with two squares consid�ered adjacent if they share a side� Soon they found the game prettyboring� Can you guess why�
��� Sperner�s theorem on independent systems
Yes� this is the second time that we meet the name Sperner in thischapter� but Sperner�s theorem� which we consider next� deals withsomething quite di�erent than Sperner�s lemma of the previous sec�tion� It is about an n�element set X and a system M of its subsets�We call the systemM independent if it contains no two di�erent setsA�B such that A � B� Before reading further� you may want to try�nding an independent set system on a ��element set with as manysets as possible� How many sets can you get�
����� Theorem �Sperner�s theorem�� Any independent system
of subsets of an n�element set contains at most� nbn��c
�sets�
This is in fact a theorem on partially ordered sets �posets� Con�sider the set system �X consisting of all subsets of the set X� Therelation �� �to be a subset of�� is a partial order on �X �it is even oneof the most important examples of a partial order� see Section ����An independent system of sets is exactly a set of pairwise incompar�able elements in the poset ��X ��� A set of pairwise incomparableelements in a poset is commonly called an antichain� and so Sperner�stheorem gives an upper bound on the size of any antichain in ��X ���
��� Doublecounting
Before we start proving Sperner�s theorem� we should remarkthat the upper bound in that theorem is certainly the best possible�because all subsets of X of size bn��c constitute an independentsystem of size exactly
� nbn��c
��
Proof of Theorem ������ We �rst say what a chain of subsetsof X is� it is any set fA�� A�� � � � � Akg of subsets of X such thatA� � A� � � � � � Ak� In the language of ordered sets� it is simply alinearly ordered subset of the poset ��X ���
The key observation is that any chain has at most one element incommon with any antichain� For example� if we succeeded in provingthat the whole poset in question can be expressed as a union of atmost r chains� then no antichain would have more than r elements�Our proof uses this simple observation in a more sophisticated way�however�
We consider the maximal chains in ��X ��� where a maximalchain is a chain such that if we add to it any other set of �X � theresult is no longer a chain� It is easy to see what the maximal chainslook like� they contain one subset of X of each of the possible sizes�that is� they have the form
� � fx�g � fx�� x�g � fx�� x�� x�g � � � � � fx�� x�� � � � � xng� ����
where x�� x�� � � � � xn are all elements of X written out in some arbi�trary order� Every maximal chain therefore induces a linear order�ing of elements of X� and� on the other hand� every linear orderingyields exactly one maximal chain� As a result� the number of maxi�mal chains equals the number of permutations of X� i�e� n��
LetM be an antichain �an independent system of subsets� Formall ordered pairs �R�M� where M �M is a set and R is a maximalchain containing M � We count such pairs in two ways�
First� by the observation mentioned above� every chain containsat most one M �M �because M is an antichain� so the number ofpairs �R�M is less than or equal to the number of maximal chains�which is n��
On the other hand� we can take a set M � M and ask howmany maximal chains contain it� A maximal chain of the form ����contains M if and only if fx�� x�� � � � � xkg � M � where k � jM j�Hence we ask how many linear orderings of X there are such thatthe �rst k elements are just the elements of M � We can still orderthe elements of M in k� ways� thus determining the �rst k sets of the
��� Sperner�s theorem on independent systems ���
chain� and the elements outside M can be ordered in �n� k� ways�which determines the rest of the chain� Altogether M is contained ink��n � k� maximal chains� So the number of ordered pairs �R�Mis equal to X
M�MjM j��n� jM j��
while according to the �rst way of counting� it is at most n�� Dividingthe resulting inequality by n�� we obtain
XM�M
jM j��n� jM j�n�
�X
M�M
�� njM j
� � �� ����
We use the fact that� nbn��c
�is at least as large as any binomial
coe�cient of the form�nk
�� k � �� �� � � � � n� Therefore
� �X
M�M
�� njM j
� � jMj �� nbn��c
� �and hence jMj � � n
bn��c�� �
The remarkable inequality ��� is called the LYM inequality� afterits independent discoverers Lubell� Meshalkin� and Yamamoto�
Another proof of Sperner�s theorem� As with many other impor�tant theorems� Sperner�s theorem can be proved in several essentiallydi�erent ways� From each of the various proofs one can learn somethingnew� or just enjoy the beautiful ideas� We will describe two more proofmethods� The �rst one cleverly covers �X with chains of a special type�Let us consider a chain in the poset �X ��� i�e� a sequence of sets
in inclusion� M� � M� � � � � � Mt� Call such a chain symmetric if itcontains one set of size k� one set of size k��� one set of size k���� � � �one set of size n�k� and no other sets for some number k� For example�for n � �� the chain consisting of the sets f�g and f�� �g is symmetric�as well as the chain f� f�g� f�� �g� f�� �� �gg� but the chains ff�gg andf� f�� �� �gg are not symmetric in this sense� A partition into symmetricchains is a way of expressing �X as a union of several disjoint symmetricchains�Any partition into symmetric chains if it exists at all has to con�
sist of exactly�
nbn��c
�symmetric chains� because each symmetric chain
contains exactly one set of size bn��c� Each chain has at most one set incommon with any independent set system this was the basic observa�tion in the �rst proof of Sperner�s theorem� Hence Sperner�s theoremis a consequence of the following�
��� Doublecounting
Claim� For any nite set X� the system �X has a partition into symmetric chains�
Proof of the claim� We may assume that X � f�� �� � � � � ng� The proofis based on the following construction�To each setM � X � we assign a sequence �m�m� � � �mn� consisting
of left and right parentheses by the rule
mi �
��� if i �M�� if i ��M �
For example� for n � � and the set M � f�� �g� we get the sequence�m�m� � � �m �� ��� The resulting sequence of parentheses isquite general� and certainly it need not be a �correct� parenthesizing�i�e� the left and right parentheses need not match� We can get a �partialpairing of parentheses� from it� however� First� we pair up all pairs ��of adjacent parentheses� Then we ignore these already paired parenthe�ses� and we continue pairing up the remaining parentheses according tothe same rule� Here are two examples�
��z ��z ��z ��z � �z
After �nishing this pairing procedure� some parentheses may remainunmatched� But the rule of the pairing implies that the sequence of theremaining unmatched parentheses has only closing parentheses on thebeginning and then� from some position on� only opening parentheses�We say that two sequences of parentheses have the same partial
pairing if the paired parentheses are the same in both sequences alsoin the same positions� This is the case for the sequences correspondingto the � sets below the sets are regarded as subsets of f�� �� � � � � ��g�
M� � f�� �� �� �� ��g � � � M� � f�� �� �� ��g � � � M� � f�� �� �g � � �
The only way two sequences with the same partial pairing may di�eris that one has more unmatched right parentheses on the left than theother� From this it is easy to see that two sets with the same partialpairing of the corresponding sequences of parentheses have to be ininclusion one is a subset of the other�We now de�ne an equivalence � on the set �X� by letting M � M �
hold if and only if bothM andM � have the same partial pairing of theirsequences� We claim that each class of this equivalence is a symmetric
��� Sperner�s theorem on independent systems ���
chain� We leave the veri�cation as an easy exercise� So we have provedSperner�s theorem once more� �
Finally we demonstrate one more proof of Sperner�s theorem� It isremarkably di�erent from the previous two proofs� and it uses the highlysymmetric structure of the poset �X ���We begin with a general de�nition which has already been men�
tioned in Exercise ������ Let X�� and Y�� be some posets� Amapping f �X � Y is called an isomorphism of posets if f is a bi�jection and for any two elements x� y � X � x � y holds if and onlyif fx � fy� An isomorphism of a poset X�� onto itself is calledan automorphism of X��� An automorphism preserves all propertieswhich can be de�ned in terms of the ordering relation �� For example�x is the largest element� of some subset A � X if and only if fx isthe largest element of the set fA� and so on�
Third proof of Sperner�s theorem� Let X be a given n�elementset� Each permutation f �X � X induces a mapping f�� �X � �X i�e�sending subsets of X to subsets of X given by f�A � ffx� x � Ag�It is clear that f� is a bijection� �X � �X � and even an automorphismof the poset �X ���Let us now consider a systemM of subsets of the set X � For each
permutation f of the set X � we get the set system ff�M� M � Mg�that is� the system of images of the sets from M under the mappingf�� In this way� we have de�ned a new mapping
f��� ��X � ��
X
assigning set systems to set systems by the formula
f��M � ff�M� M � Mg�The mapping f�� is again a bijection�We introduce a relation � on the set of all set systems on X i�e� on
the set ��X
�
M�N � for each M � M there exists an N � N with M � N �
Note that the relation � is something di�erent than the inclusion be�tween set systems� It is a possibly larger relation than inclusion hence
�The largest element was de�ned in Exercise ������In Section ��� we adopted a convention according to which one can write
the image of a set under some mapping in the same way as for the image of anelement� That is� in our case we could write the set ff�x�� x � Ag simply as f�A��In the present proof� however� it is better to distinguish more exactly betweenthe image of an element and the image of a set� That is why we have introduceda di�erent symbol� f�� for the mapping of sets�
��� Doublecounting
M� N impliesM�N � The reader is invited to check that the rela�tion � is re�exive and transitive� but that it need not be antisymmetric�nd an example on a ��element set X�Let the letter . stand for the set of all independent set systems on
the set X so . � ��X � We claim that the relation � restricted to .is already antisymmetric� and consequently it is a partial ordering on.� Indeed� ifM and N are independent systems of sets such that bothM�N andN�M� we consider an arbitrary setM � M� The systemNhas to contain some setM � �M � and thenM contains someM �� �M �
too� Thus we getM�M �� �M with M �M ��� and by the independenceof M it follows that M � M �� � M �� and hence M � N � This showsthatM� N � and symmetrically we obtain N �M� whenceM � N �Thus .�� is an ordered set�Further we claim that for any permutation f � the mapping f�� is
an automorphism of the poset .���we leave the veri�cation to thereader this is a good way to really understanding of the notions like .and f���The proof of Sperner�s theorem is based on the following lemma�
Lemma� Let .� � . denote the set of the independent set systemswith the largest possible number of sets� The set .� has a largest elementN� with respect to the ordering by �� This means M � N� for allM� .��Proof of the lemma� Since there are only �nitely many set systems onX � it su�ces to prove that for any two set systemsM�M� � .�� thereexists a set system N � .� that is larger than both M and M�� i�e�M�N andM�
�N �So we consider some M�M� � .�� and we form a new set system
,M � M �M�� Since both M and M� are independent� the longestchain in ,M� with respect to the ordering of ,M by inclusion� has atmost two sets� Next� let ,Mmin be the system of all sets from ,M forwhich ,M contains no proper subset� or in other words the system ofall sets of ,M minimal with respect to inclusion� Similarly we introducethe system ,Mmax as the system of all inclusion maximal sets of ,M� Wewant to check that the system N � ,Mmax belongs to .� and satis�esbothM� ,Mmax andM�
� ,Mmax�Both the systems ,Mmin and ,Mmax are independent� and we have
,M � ,Mmin � ,Mmax� Clearly also ,Mmax �M and ,Mmax �M�� Itremains to verify that ,Mmax has the largest possible number of sets�i�e� j ,Mmaxj � jMj� Let us note that by the independence ofM andM��we getM�M� � ,Mmin � ,Mmax check�� Hence j ,Mminj� j ,Mmaxj �j ,Mmin� ,Mmaxj�j ,Mmin� ,Mmaxj jM�M�j�jM�M�j � jMj�jM�j�and so if we had j ,Mmaxj � jMj � jM�j then we would get j ,Mminj �jMj and the systemsM andM� would not have the maximum possiblesize� This proves the lemma�
��� Sperner�s theorem on independent systems ���
It remains to �nish the third proof of Sperner�s theorem� Let us con�sider the largest element N� of the set .���� For each permutationf of the set X � the corresponding induced automorphism f�� mapsthe set .� independent systems of maximum size onto itself� and soit must map its unique largest element N� onto itself� f
��N� � N��This implies� however� that if N� contains at least one k�element setthen it already contains all k�element sets� In other words�
�Xk
� � N��
It is impossible to add any set to the system�Xk
�so that it remains
independent� and thus N� ��Xk
�� The maximality of the binomial co�
e�cients�
nbn��c
�and
�n
dn��e�then implies that N� �
�X
dn��e�� �
Exercises
�� Let us call a system N of subsets of X semiindependent if it containsno three sets A�B�C such that A � B � C�
a Show by a method similar to the �rst proof of Sperner�s theoremthat jN j � �� n
bn��c�� where n � jX j�
b Show that for odd n� the estimate from a cannot be improved�
�� a Determine the number of maximal chains in the set f�� �� � � � � � �gordered by the divisibility relation�
b Count the number of maximal antichains in the set f�� �� � � � � ��gordered by the divisibility relation�
�� �Show that the set systems�
Xbn��c
�and
�X
dn��e�are the only indepen�
dent set systems on an n�element set X with the largest possible num�ber of sets�
�� Determine the number of automorphisms of the poset �X ����� By modifying the third proof of Sperner�s theorem� show that for any�nite poset P�� there exists an antichain of maximum possible sizethat is mapped to itself by all automorphisms of P�� i�e� it is a��xed point� of all automorphisms�
�� Let a�� a�� � � � � an be real numbers with jaij �� Let pa�� � � � � an bethe number of vectors ��� ��� � � � � �n� where �i � �� such that
�� �nXi��
�iai � ��
a �Prove that for any a�� a�� � � � � an we have pa�� � � � � an ��
nbn��c
��
This is one of the �rst applications of Sperner�s theorem�the so�called Littlewood$O�ord problem�
b Find a�� a�� � � � � an with pa�� � � � � an ��
nbn��c
��
��� Doublecounting
�� Let n be a natural number that is not divisible by the square of anyinteger greater than �� Determine the maximum possible size of a setof divisors of n such that no divisor in this set divides another i�e�max jM j� where x �M � xjn and x� y �M � x �� y � x doesn�t dividey�
�� Let X�� be a poset with n elements� Let c stand for the length of thelongest chain in X�� and a for the length of the longest antichain�a �Show that X can be expressed as a disjoint union of at mostc antichains this implies that there exists an antichain with at leastdn�ce elements�b ��Dilworth�s theorem Show that X can be expressed as a dis�joint union of at most a chains�
�� Erd/os$Szekeres lemma
a �Show that for an arbitrary sequence a�� a�� � � � � an of pairwisedistinct real numbers there exist indices i�� i�� � � � � ik� where � � i� �i� � � � � � ik � n and k � dpn e� such that either ai� � ai� � � � � �aik the terms aij form an increasing subsequence� or ai� � ai� �� � � � aik the terms aij form a decreasing subsequence� You can useExercise �a�
b Show that the bound on k in a cannot be improved in general�that is� there exists an n�element sequence containing no increasing ordecreasing subsequence with more than dpn e terms�c This time we consider two sequences a � a�� � � � � an and b �b�� � � � � bn of pairwise distinct numbers� Show that indices i�� � � � � ik�� � i� � � � � � ik � n� always exist with k � dn���e such thatthe subsequences determined by them in both a and b are increasingor decreasing all � combinations are allowed� e�g� �increasing in a�decreasing in b�� �decreasing in a� decreasing in b�� etc��
d �Show that the bound for k in c cannot be improved in general�
��� A result in extremal graph theoryIn some situations� we know that a graph G� usually with many vertices�does not contain a certain graph or a graph of a certain type as a sub�graph� and we are interested in �nding the maximum possible numberof edges G may have� For instance� if we know that a given graph onn vertices contains no cycle then it is a tree or a forest� and so it hasat most n � � edges� We can also use the converse of this statement�if a graph on n vertices has at least n edges then it contains a cycle�This is a very simple example� and for other �forbidden� subgraphs thesituation is more complicated� some of the corresponding problems havenot yet been completely solved� The branch of mathematics concernedwith questions of this type is called extremal graph theory� We present
��� A result in extremal graph theory ���
one of its lovely results� actually the historically �rst result from ����due to Erd/os� concerning forbidden K��� the complete bipartite graphon � � � vertices� which happens to be the cycle of length ��
����� Theorem� If a graph G on n vertices contains no subgraph
isomorphic to K��� then it has at most ��
�n��� % n
�edges�
Remark� This means that by forbidding K���� the number of edgesgoes down a lot� from roughly �
�n� edges for an arbitrary graph
to roughly ��n
��� edges for a graph without K���� This contrastswith the fact that if we forbid� say� a triangle �K�� then we canstill have about n��� edges� �Consider the complete bipartite graphKbn��c�dn��e� As we will see later �Theorem ������ the bound inTheorem ����� is nearly the best possible for large n�
Proof� Let us write V � V �G� We will double�count the size ofthe set M of all pairs �fu� u�g� v� where v � V � fu� u�g � �V
�
�� and v
is connected by an edge to both u and u�� In other words� we count�noninduced subgraphs of the form
v
u
u�
For a �xed pair fu� u�g� only one vertex v � V may exist joined toboth u and u�� If there were two such vertices� v and v�� they wouldtogether with u and u� form a subgraph isomorphic to K���� HencejM j � �n
�
��
Now let us see how many elements of the form �fu� u�g� v are con�tributed to the set M by a �xed vertex v � V � For each pair fu� u�gof its neighbors� v contributes one element of M � so if v has degree dit contributes
�d�
�elements� Therefore� if we denote by d�� d�� � � � � dn
the degrees of the vertices of V � we obtain jM j � Pni��
�di�
��
Combining this with the previous estimate� we getnXi��
�di�
���n
�
�� ����
At the same time� the number of edges of the considered graph is��
Pni�� di� The rest of the proof is just a manipulation of inequalities
which can be done in many di�erent ways�Here we show one proof� and another is sketched in Exercise �
�the latter proof is a bit more complicated but it can be generalizedmore easily� First� we need a famous and generally useful inequality�
�� Doublecounting
����� Proposition �Cauchy�Schwarz inequality�� For arbitra�
ry real numbers x�� x�� � � � � xn and y�� y�� � � � � yn we have
nXi��
xiyi �vuut nX
i��
x�i
vuut nXi��
y�i �
A proof is indicated in Exercise � �and usually it is treated incalculus courses� Let us remark that the Cauchy�Schwarz inequalityhas a nice geometric meaning� If we interpret x � �x�� � � � � xn andy � �y�� � � � � yn as vectors in the n�dimensional Euclidean space�the left�hand side of the inequality is the scalar product of x and y�while the right�hand side is the product of the lengths of the vectors�check this for n � �� i�e� in the plane� provided you know at least alittle about vectors� A well�known formula for vectors says that thecosine of the angle of two vectors equals their scalar product dividedby the product of their lengths� The Cauchy�Schwarz inequality thusamounts to saying that this cosine is never greater than ��
Finishing the proof of Theorem ������ Obviously� we can as�sume that our graph has no isolated vertices� and hence di � � forall i� Then we have
�di�
� � �� �di � ��� and so we obtain from ����
thatnXi��
�di � �� � n��
We now apply the Cauchy�Schwarz inequality with xi � di � ��yi � �� We get
nXi��
�di � � �vuut nX
i��
�di � ��pn �
pn�pn � n����
so jE�Gj � ��
Pni�� di � �
��n��� % n� �
The intuition� In the proof� we have derived an upper bound forthe sum
Pni��
�di�
�� and we ask how large the sum
Pni�� di can be� For
di not too small��di�
�behaves roughly like �
�d�i � Given that
Pd�i is
about n�� the way to makePdi largest is to choose all the di equal�
which in our case means each should bepn� Then
Pdi is about n
����Of course� this is not a proof� but such a rough calculation can oftengive us a good idea about what is going on� The above proof with theCauchy�Schwarz inequality is a polished version of the same idea�
��� A result in extremal graph theory ���
Exercises
�� Prove that for any t �� the maximum number of edges of a graphon n vertices containing no K��t as a subgraph is at most
�
�
�pt� �n��� � n
��
�� Let X be an n�element set� and let S�� S�� � � � � Sn be subsets of X suchthat jSi � Sj j � � whenever � � i � j � n� Prove that at least oneof the sets Si has size at most C
pn� for some absolute constant C
independent of n�
�� Let G be a bipartite graph with vertex classes of size n andm� Supposethat G contains no K��� as a subgraph� Prove that G has at mostOm
pn�n edges� Note that for n much larger than m� this is better
than the bound from Theorem ������
�� a Prove the Cauchy$Schwarz inequality by induction on n squareboth sides �rst�
b Prove the Cauchy$Schwarz inequality directly� starting from theinequality
Pni�j��xiyj � xjyi
� ��� a Let f �R � R be a convex function� i�e� for any x� y � R and
� � � � �� we have f�x����y � �fx����fy� Geometrically�this means that if we connect any two points on the graph of f by asegment� then no part of this segment reaches below the graph of f �
x y
y � fx
�x� �� �y
Prove by induction that for f convex� the inequality
f��nx� �
�nx� � � � �� �
nxn� � �
nfx� ��nfx� � � � �� �
nfxn ���
holds for any real numbers x�� x�� � � � � xn this is sometimes calledJensen�s inequality�
b De�ne a function f by the formula
fx �
� for x � �xx � ��� for x � ��
Prove that f is convex�
��� Doublecounting
c Prove Theorem ����� from ��� using a and b� First deriven � f � m�n� � �
n�
�� where m � jEGj�
�� �In a way similar to the method in Exercise �� deduce that if a graphon n vertices does not contain K��� as a subgraph then it has On
���edges�
�� a �Let L be a set of n distinct lines in the plane and P a set of ndistinct points in the plane� Prove that the number of pairs p� ��where p � P � � � L� and p lies on L� is bounded by On����
Remark� It is known that the right bound is On���� see Pach andAgarwal �����
b �Show that the bound in a remains valid if lines are replaced bycircles of unit radius� Use Exercise ��
Remark� Here the best known upper bound is On��� as well� butit is suspected that the number of incidences is actually bounded byOn��� for an arbitrarily small constant � � with the constanthidden in the O� notation depending on �� Proving ot disprovingthis is a very challenging open problem�
�
The number of spanningtrees
��� The result
For a given graph G� let T �G denote the number of all spanningtrees of G� For example� we have T �K� � � �so we really countall possible spanning trees� not just nonisomorphic ones� In thischapter� we present several proofs of the following result�
���� Theorem �Cayley�s formula�� For each n � �� the numberT �Kn� i�e� the number of trees on given n vertices� equals nn���
Although T �Kn can be expressed in such a nice and simple way�no completely straightforward method is known for deriving the for�mula� In the course of time� many proofs have been discovered� Theirbasic ideas di�er substantially� but each of them involves a clevertrick or follows from a nontrivial theory� We have collected severalof these proofs into this chapter �by far not all known ones�� mainlyas an illustration of the richness of mathematical thought�
The proof in Section ��� counts the number of spanning trees witha given score by a clever induction� Section ��� presents an elegantargument constructing a bijection between the set of all spanningtrees of Kn with two marked vertices and the set of all mappingsf�� �� � � � � ng � f�� �� � � � � ng� Section ��� is a classical proof withencoding trees by sequences of length n � �� Finally the method ofSection ��� is the most advanced one and it gives perhaps the bestinsight into the problem� It expresses the number of spanning treesof an arbitrary graph as a certain determinant� Yet another proof issketched in Exercise ������
By no means do we want to claim that Theorem ����� belongs amongthe most fundamental results in mathematics� On the other hand� thenumber of spanning trees of a graph and the related theory has many
��� The number of spanning trees
theoretical and practical applications� and it was �rst studied in con�nection with electrical circuits�As an illustration� let us mention without a proof an �electrotechni�
cal� meaning of the number of spanning trees of a graph� Imagine thata given graph G is an electrical circuit� where each edge is a wire ofunit resistance and the vertices are simply points where the wires areconnected together� If x and y are vertices connected by an edge� thenthe resistance we would measure between x and y in this circuit equalsthe number of spanning trees of G containing the edge fx� yg dividedby the total number of spanning trees� T G� This result is not toouseful directly for applications because the resistances are seldom allidentical� but a generalization exists for graphs with weights on edges�More about the subject of this chapter can be found in Lov'asz ��� orBiggs �����
In the whole chapter� we assume that the vertex set V of theconsidered graph G is the set f�� �� � � � � ng�
Exercises
�� Prove that the number of nonisomorphic trees on n vertices is at leasten���n� see also Exercise �������
�� �Assume the validity of Theorem ������ and determine the number ofspanning trees of the complete graph on n vertices minus one edge�
�� Put Tn � T Kn� Prove the recurrent formula
n� �Tn �n��Xk��
kn� k
�n� �k � �
�TkTn�k�
Remark� Theorem ����� can be derived from this recurrence too� butit�s not so easy�
�� �Let G be a connected topological planar graph� and let G� denote itsdual as in De�nition ������ Prove that T G � T G�� If convenient�you may assume that G is such that G� has no loops and no multipleedges�
��� A proof via scoreFirst we count the number of trees with a given score�
���� Proposition� Let d�� d�� � � � � dn be positive integers summing
up to �n� �� Then the number of spanning trees of the graph Kn inwhich the vertex i has degree exactly di for all i � �� �� � � � � n equals
�n� ��
�d� � ���d� � �� � � � �dn � ���
��� A proof via score ���
Proof� By induction on n� For n � �� �� the proposition holdstrivially� so let n � �� Since the sum of the di is smaller than �n�there exists an i with di � �� We now do the proof assuming thatdn � �� This is just for notational convenience� exactly the sameargument works for any other di � � �or� put di�erently� the numberof the spanning trees of the required type obviously doesn�t changeby exchanging the values of dn and di so we may assume dn � �without loss of generality�
Let T be the set of all spanning trees ofKn with the given degrees�i�e� in which each vertex i has degree di� Classify the trees of T inton�� groups T�� � � � �Tn��� the set Tj consists of all trees of T in whichthe vertex n is connected to the vertex j� Next� we consider a treefrom Tj� and we delete the vertex n together with its �single edge�We obtain a spanning tree of Kn��� whose degree at the vertex i is difor i � j and dj�� for i � j� It is easy to see that in this way� we geta bijection between the set Tj and the set T �
j of all spanning treesof Kn�� with degrees d�� d�� � � � � dj��� dj � �� dj�� � � � � dn�� �sincedistinct trees of Tj give rise to distinct trees of T �
j � and from eachtree of T �
j we can get a tree of Tj by adding the vertex n back andconnecting it to the vertex j�
By the inductive hypothesis� we have
jTjj � jT �j j
��n� ��
�d� � �� � � � �dj�� � ���dj � ���dj� � �� � � � �dn�� � ��
��n� ���dj � �
�d� � ���d� � �� � � � �dn�� � ���
This formula also holds when dj � �then it gives � which agreeswith the fact that no spanning tree with degree dj � � � � at thevertex j exists�
Therefore� the total number of spanning trees on n vertices withdegrees d�� d�� � � � � dn� where dn � �� is
jT j �nX
j��
jTjj �n��Xj��
�n� ���dj � �
�d� � ���d� � �� � � � �dn�� � ��
�
� n��Xj��
�dj � �
��n� ��
�d� � ���d� � �� � � � �dn�� � ��
��� The number of spanning trees
��n� ��n� ��
�d� � ���d� � �� � � � �dn�� � ���
Since dn � �� we can multiply the denominator by the factor�dn � �� � �� � � with no harm� and this �nishes the inductivestep� �
Next� we prove Theorem ������ We will sum over all possible scoresof spanning trees� and we will use the multinomial theorem ������
T �Kn �X
d��d������dn��d��d������dn��n��
�n� ��
�d� � ���d� � �� � � � �dn � ��
�X
k��k������kn�n��k������kn��
�n� ��
k��k�� � � � kn� � �� % � % � � �% �� �z n�
n�� � nn���
�
Exercises
�� a �Find the number of trees on given n vertices in which all verticeshave degree � or ��
b �What if we allow degrees �� �� or ��
�� Yet another proof of Theorem ����� Let Nk denote the numberof spanning trees of Kn in which the vertex n has degree k� k ��� �� � � � � n� � recall that we assume V Kn � f�� �� � � � � ng�a �Prove that n� �� kNk � kn� �Nk���
b Using a� derive Nk ��n��k��
�n� �n���k�
c Prove Theorem ����� from b�
��� A proof with vertebrates
Consider a spanning tree of the complete graph Kn� Mark one of itsvertices by a circle� and one vertex by a square� as in Fig� ����a� Wedo not exclude the case that the same vertex is marked by both acircle and a square� Each object that can arise in this way from somespanning tree on Kn is called a vertebrate� Let V denote the set ofall vertebrates �for the considered value of n�
From each given spanning tree� we can create n� vertebrates�Therefore the number of all spanning trees equals jVj�n�� We nowshow
��� A proof with vertebrates ���
���� � � � ��
�
�
�
��
��
��
��
��
�� ��
��
��
�
��
��
��
��� ��
���
���
��
���
�
�
�
�a �b
Fig� ��� a A vertebrate on �� vertices� b the corresponding mapping�
Lemma� There exists a bijection F between the set V of all verte�
brates and the set of all mappings of the vertex set V to itself�
Since the number of all mappings of an n�element set to itselfis nn� the number of vertebrates is the same by the lemma� andtherefore the number of spanning trees is nn���
Proof of the lemma� We demonstrate the de�nition of the bijec�tion F on the example in Fig� ���� We start from the vertebrate Wdrawn in Fig� ����a� The marked vertices � and� are connected bya unique path� which we call the chord� Let us write out the numbersof vertices of the chord ordered by magnitude� Then� we write thesenumbers again on the next line� in the order as they appear alongthe chord from � to ��
� � � � � �� ��� � �� � � � ��
We de�ne an auxiliary directed graph P � the vertex set consists ofthe vertices of the chord� and we make an arrow �directed edgefrom each vertex written in the �rst line to the vertex below it in thesecond line� Since there is exactly one arrow going from each vertexand also exactly one arrow entering it� the graph P is a disjoint unionof directed cycles �including possibly also isolated vertices with adirected loop� We can also say that the chord de�nes a permutationof its vertices� and P consists of the cycles of this permutation �seeSection ���� In our example� these cycles are ��� �� �� ��� ��� ���and ����
We now look back at the whole vertebrate W � If we remove theedges of the chord from it� it splits into components �which are treesagain� We direct the edges of the components so that they point to
��� The number of spanning trees
the �single vertex of the chord contained in that component� Thisgives rise to one more set of directed edges on the set V � We nowde�ne a directed graph with vertex set V � its edges are all directededges of the components� plus the edges of the graph P � In the �gure�this is very intuitive� We draw the cycles of the graph P � and then wedraw to each vertex �originally coming from the chord the tree thatwas hanging by that vertex on the chord of the considered vertebrate�see Fig� ����b�
We claim that the resulting directed graph�G� is a graph of a map�ping� i�e� there is exactly one arrow going from each vertex� For thevertices of the chord� this has already been mentioned� For the othervertices� the reason is that there is a unique path to the chord fromeach vertex in the vertebrate W � Using the graph G� we can �nallyde�ne a mapping f � f�� �� � � � � ng � f�� �� � � � � ng� for each i � V � weset f�i � j� where j is the vertex of G that the arrow emanatingfrom i ends in� In our speci�c example� we get the mapping � �� ��� �� ��� � �� �� � �� �� � �� �� � �� �� � �� ��� � �� �� � �� �� �� �� ���� �� ��� �� �� �� �� �� ��� �� �� �� �� �� ��� �� �� �� �� �� ����� �� �� and �� �� �� In this way� each vertebrate W determines amapping F �W �
It remains to prove that the original vertebrate W can be re�constructed from the mapping f produced as above� and that everymapping can be obtained from some vertebrate� This is left as anexercise� �
Exercises
�� For a mapping f �V � V � where V is a �nite set� we de�ne the di�rected graph of f as the directed graph with vertex set V and edge setfi� fi� i � V g such a graph was used in the proof above� Provethat each weakly connected component of such a graph is a directedcycle� possibly with some trees hanging at the vertices of the cycle�with edges directed towards the cycle�
�� Given a mapping f � f�� �� � � � � ng � f�� �� � � � � ng of the form F W for some vertebrate W � describe how the vertebrate W can be recon�structed from the knowledge of f � Prove that any mapping f can beobtained as F W for some vertebrate W use Exercise ��
�� ��CS Let f � f�� �� � � � � ng � f�� �� � � � � ng be a mapping� For each i �f�� �� � � � � ng� the sequence i� fi� ffi� � � � must be eventually pe�riodic� Design an algorithm that �nds the shortest period of this se�quence for a given i� That is� in the language of the directed graph
��� A proof using the Pr�ufer code ���
of the mapping f � we want to �nd the length of the directed cycle inthe component containing the vertex i� The algorithm should use onlyan amount of memory bounded by some constant independent of n� Ithas a subroutine black box at its disposal for evaluating the functionf for any given i�
�� CS a Design the details of an algorithm for producing a vertebratefrom a mapping� How many steps does it need in the worst case� �Canyou make it run in On time�
b �Program the algorithm from a� and use it to generate randomspanning trees of the complete graph from randomly generated map�pings� Using this program� experimentally estimate the average expec�tation of the maximum degree and the diameter of a random spanningtree on a given number of vertices � �� say�
��� A proof using the Pr�ufer code
We show how each spanning tree of the complete graph Kn can beencoded by an �n� ��term sequence such that each term is one ofthe numbers �� �� � � � � n� This coding will de�ne a bijection betweenall spanning trees and all sequences of the type just described� Sincethe number of such sequences is obviously nn��� this will establishTheorem ������
Consider a spanning tree T � our running example on � verticesis drawn in Fig� ����a� We explain how to construct a sequencep � P �T � �p�� p�� � � � � pn��� the so�called Pr"ufer code of the tree T �The basic idea� is to tear o� the leaves of T one by one until thetree is reduced to a single edge� We will thus construct an auxiliarysequence T� � T� T�� T�� � � � � Tn�� � K� of trees� and produce thesequence p simultaneously� Suppose that the tree Ti�� has alreadybeen constructed for some i �initially we have T� � T � As we know�this Ti�� has at least one leaf �i�e� a vertex of degree �� We takethe smallest of the leaves of Ti�� �recall that the vertices of T arethe numbers �� �� � � � � n� and we form Ti by removing this leaf fromTi�� together with the edge incident to it� At the same time� we alsode�ne the ith term� pi� of the constructed sequence as the neighborof the leaf just torn o� from Ti��� This is the main trick� we donot record the leaf but its neighbor� By doing this successively fori � �� �� � � � � n� �� we have de�ned the whole sequence p � P �T �
Now we derive how to reconstruct the original tree T � P���pfrom the sequence p � �p�� p�� � � � � pn��� More exactly� we give a rule
�A somewhat vandalic one�
�� The number of spanning trees
�
��
�
� � �
�
�
��
�
�� �
step �
step �
step � step �step �
�a �b
Fig� ��� a A spanning tree with code �� �� �� �� �� �� b the procedure
of its reconstruction from the code�
creating a spanning tree from each given sequence p� and we proceedin such a way that if p arose from some spanning tree T then our rulegives us back the tree T � This will show that the coding of spanningtrees by sequences indeed de�nes a bijection as we claimed�
So let us suppose that a given sequence p arose by the above�described construction from some �as yet unknown spanning tree T �Let �� denote the leaf of T that was removed �rst� How can wetell �� from the sequence p� This �� cannot occur anywhere in thesequence p �since we wrote only vertices still present in the currenttree into the sequence p� Further� any vertex not contained in theset fp�� p�� � � � � pn��g has to be a leaf of the tree T�� for otherwise wewould sooner or later tear o� a leaf hanging from it� and it wouldappear in the sequence p at that moment� According to the rule forremoving leaves� �� must thus be the minimum element of the setf�� �� � � � � ng n fp�� p�� � � � � pn��g� Now we can draw the vertices ��and p� and connect them by an edge �see Fig� ����b�
Further� we proceed similarly� Having found the leaves ��� ��� � � � ��i�� removed from T in the steps � through i� �� we determine theleaf �i� It cannot be any of the vertices pi� pi�� � � � � pn��� and neitherany one of ��� � � � � �i��� of coursetherefore �i is the minimum of theset f�� �� � � � � ngnfpi� pi�� � � � � pn��� ��� ��� � � � � �i��g� We connect this�i by an edge to the vertex pi� if �i has not been drawn yet� we drawit as well� and similarly for pi� The �rst � steps of this constructionare depicted in Fig� ����b� In the �th step� we would draw the edgef�� �g�
After n�� steps� we have drawn n�� edges of the spanning treeT � namely all the edges that have been removed in the construction
�� A proof working with determinants ���
of p� It remains to deduce which edge was the last remaining one�One of its endpoints must be pn��� i�e� the neighbor of the last leaftorn o�� and the other endpoint is the vertex not occurring amongthe removed leaves ��� � � � � �n�� and distinct from pn��� In Fig� ����this edge is f�� �g� This �nishes the description of the reconstructionprocedure� and the considerations made along the way also con�rmits correctness�
It remains to note that this algorithm executes properly for anarbitrary input sequence p� since the set from which �i is chosen isalways nonempty� and thus we obtain a spanning tree of Kn for eachinput sequence p� So we have indeed de�ned a bijection� �
Exercises
�� Let T be a spanning tree of Kn� and let p � P T be its Pr&ufer code�Let mi be the number of times the vertex i appears in the sequence p�i � �� �� � � � � n� Prove that degT i � mi � � holds for all i�
�� CS a Design the details of an algorithm for producing a spanningtree of Kn from its Pr&ufer code� How many steps does it need in theworst case� �Can you make it run in On logn time� or even faster�b �Program the algorithm from a� Use it as in part b of Exer�cise ������ Which of the two algorithms runs faster�
��� A proof working with determinantsThe proof of Theorem ����� given in this section is based on linearalgebra� and it illustrates a nice combinatorial meaning of the deter�minant �the de�nition and facts about determinants we need can befound in the Appendix� It is somewhat more di�cult than the pre�vious proofs and it requires basic results concerning determinants�but it provides a formula for the number of spanning trees of anarbitrary graph�
Let G be an arbitrary graph with vertices �� �� � � � � n� n � �� andwith edges e�� e�� � � � � em� We introduce an nn matrix Q� called theLaplace matrix of the graph G� whose elements qij are determinedby the following formula�
qii � degG�i i � �� �� � � � � n
qij �
��� for fi� jg � E�G� otherwise
i� j � �� �� � � � � n� i � j�
Further� let Qij denote the �n� � �n� � matrix arising from thematrix Q by deleting the ith row and the jth column�
��� The number of spanning trees
The following remarkable theorem holds�
���� Theorem� For every graph G� we have T �G � detQ���
Let us remark that also T �G � jdetQij j holds for any two indicesi� j � f�� �� � � � � ng� We do not prove this here� a proof is indicated inExercise ��
Before we start proving Theorem ������ we calculate the numberof spanning trees of a complete graph �Theorem ����� from it� ForG � Kn� the Laplace matrix has the number n � � everywhere onthe diagonal� and �� everywhere else� If we delete the �rst row andthe �rst column� we obtain an �n� � �n� � matrix of the form�
BBBBn� � �� �� � � � ���� n� � �� � � � �����
������ � � �
����� �� �� � � � n� �
CCCCA �
We calculate the determinant by suitable row and column operations�We subtract the �rst row from all rows except for the �rst one� andthen we replace the �rst column by the sum of all columns� We geta matrix having the numbers �� n� n� n� � � � � n on the main diagonaland zeros everywhere below the main diagonal� The determinant isthen the product of all diagonal elements� i�e� nn���
We move on to the proof of Theorem ������ First we �x somearbitrarily chosen orientation �G of the graph G� i�e� for each edge ek�we select one of its endpoints as the head and the other one becomesthe tail �see Section ��� for the terminology of directed graphs� Thisdirected edge will be denoted by �ek� Interestingly� we need someorientation for the proof� although the conclusion is independent ofthe particular orientation� and only depends on G� We de�ne anauxiliary matrix D � D �G� called the incidence matrix for the chosen
orientation �G� This matrix has n rows� corresponding to the verticesof �G� and m columns� corresponding to the edges of �G� and it isde�ned as follows�
dik �
������� if i is the tail of �ek� if i is the head of �ek� otherwise
�recall that the edges are numbered e�� � � � � em� Note that the matrixD has exactly one entry � and one entry �� in each column� the otherentries are �� and the sum of all rows is the zero vector�
�� A proof working with determinants ���
Let us recall that if A is a matrix� the symbol AT denotes thetransposed matrix A� that is� AT has the element aji at position�i� j� Next� let +D denote the matrix arising from D by deleting the�rst row� Here is a connection between the matrix D and the Laplacematrix of G�
���� Lemma� For any orientation �G of the graph G� the equalitiesDDT � Q and +D +DT � Q�� hold� where D � D �G
�
Proof� By the de�nition of matrix multiplication� the element atposition �i� j in the product DDT equals
Pmk�� dikdjk� For i � j�
the product dikdjk � d�ik is � if i is the head or the tail of the edge�ek� and it is � otherwise� and therefore the considered sum is just thedegree of the vertex i in G� For i � j� the product dikdjk is nonzeroonly if �ek � �i� j or �ek � �j� i� and in this case it equals ��� Bycomparing this with the de�nition of the Laplace matrix� we see thatDDT � Q� The second equality claimed in the lemma is a simpleconsequence of the de�nition of matrix multiplication� �
The following key lemma connects spanning trees to determi�nants�
���� Lemma� Let T be a graph on the vertex set f�� �� � � � � ng withn� � edges �n � ��� and let �T be an orientation of T � Let C � D�T
be the incidence matrix of the directed graph �T � and let +C denotethe square matrix obtained from C by deleting its �rst row� Then
det +C has one of the values �� �� ��� and it is nonzero if and only if
T is a tree �this means it is a spanning tree of the complete graph
on vertex set f�� �� � � � � ng��Proof� We proceed by induction on n� For n � �� the situationis simple� T has one edge� so it is a spanning tree� and the singleelement of the matrix +C is either � or ���
Let us consider an arbitrary n � �� and let us distinguish twocases� depending on whether any of the vertices �� �� � � � � n has de�gree � in T �
First� suppose that such a vertex of degree � exists among thevertices �� �� � � � � n� Without loss of generality� we may assume thatit is the vertex n �should it be another vertex� we simply renumberthe vertices� The vertex n belongs to a single edge� �ek� This meansthat the matrix +C has a single nonzero element in the last row �equalto � or ��� namely in the kth column�
��� The number of spanning trees
We expand the determinant of the matrix +C according to the rowcorresponding to the vertex n �this is the �n� �st row of +C�
det +C �n��Xj��
���n��j+cn���j det +Cn���j�
where +Cij denotes the matrix +C after deleting the ith row and the jthcolumn� Since the �n��st row has only one nonzero element� namely+cn���k� we get det +C � ���n��k+cn���k det +Cn���k� and thereforejdet +Cj � jdet +Cn���kj�
Let �T � be the directed graph obtained from �T by deleting thevertex n and the edge �ek� The matrix +C � arising from C � � D�T � bydeleting the �rst row is just +Cn���k� By the inductive assumption�we thus know that jdet +C �j is � or � depending on whether T � �theundirected version of �T � is a spanning tree on its vertex set or not�Since we have removed a degree � vertex from T � T is a spanning treeif and only if T � is a spanning tree� This concludes the inductive stepfor the case when at least one of the vertices �� �� � � � � n has degree �in T �
Let us discuss the second case� when none of the vertices �� �� � � � � nhas degree � in T � First we observe that T has an isolated vertex inthis case �if it were not so� the vertex � would have degree at least� and the other vertices degrees at least �� and hence the sum ofdegrees would be greater than �jE�T j � ��n��a contradiction�
Because of an isolated vertex� T is disconnected� and hence itis not a spanning tree� To �nish the proof we need to show thatdet +C � �� If there is an isolated vertex among �� �� � � � � n then itcorresponds to a zero row in the matrix +C� If the vertex � is isolatedthen the sum of all rows of +C is the zero vector because the incidencematrix D�T has zero row sum� In both cases we have det +C � �� �
By the lemma just proved� we know that the number of spanningtrees of the graph G equals the number of square �n� � �n� �submatrices with nonzero determinant of the matrix +D� For �nish�ing the proof of Theorem ������ we use an algebraic result aboutdeterminants�
���� Theorem �Binet�Cauchy theorem�� Let A be an arbi�
trary matrix with n rows and m columns� Then
det�AAT �XI
det�AI��
�� A proof working with determinants ���
where the sum is over all n�element subsets I � �f��������mgn
�� and where
AI denotes the matrix obtained fromA by deleting all columns whose
indices do not lie in I�
We give a proof of this theorem for completeness� but �rst let uslook at how the Binet�Cauchy theorem implies Theorem ������ Withthe preparation we have made� this is actually quite straightforward�By Lemma ����� and then by Theorem ����� we get
detQ�� � det� +D +DT �X
I��f��������mgn��
det� +DI��
and by Lemma ������ we see that the last expression is exactly thenumber of spanning trees of G� �
Proof of the Binet�Cauchy theorem ����� Let us denote M �AAT � We expand the determinant of M according to the de�nitionof a determinant� i�e�
detM �X��Sn
sgn��nYi��
mi���i �
where the sum is over all permutations � of the set f�� �� � � � � ng�and where sgn�� stands for the sign of the permutation � �for anypermutation� the sign is %� or ��� We will not need the de�nition ofthe sign of a permutation directly� and so we only recall the following�
���� Fact� For any permutation � of the set f�� �� � � � � ng and for
indices i� j� � � i � j � n� let the symbol �i�j denote the per�
mutation whose value at i is ��j� the value at j is ��i� and the
values for all other numbers agree with those of �� Then we have
sgn�� � �sgn��i�j�
Now we substitute the values of the elementsmij of the matrixM �namely mij �
Pmk�� aikajk� into the above expansion of the determi�
nant of M � Then we multiply out each of the products� This leadsto
detM �X�
sgn��nYi��
� mXk��
aika��i k
�
�X�
sgn��mX
k��k������kn��
nYi��
ai�kia��i �ki �
Let us change the notation in this last formula to a more suit�able one� The choice of the n�tuple k�� � � � � kn of the summation
��� The number of spanning trees
indices in the inner sum can be understood as a choice of a map�ping f � f�� �� � � � � ng � f�� �� � � � �mg de�ned by f�i � ki� With thisnew fancy notation� we thus have
detM �X�
sgn��X
f �f��������ng�f��������mg
nYi��
ai�f�i a��i �f�i �
In this sum� we exchange the order of summation� we sum accordingto the permutation � �inner sum and then according to the functionf �outer sum� For a yet more convenient notation� we introduce thesymbols
P �f� � �nYi��
ai�f�i a��i �f�i �
S�f �X�
sgn��P �f� ��
and then we have
detM �X
f �f��������ng�f��������mgS�f�
A key lemma for the whole proof is the following one�
���� Lemma� If a function f � f�� �� � � � � ng � f�� �� � � � �mg is not
injective� then we have S�f � � �for any choice of the matrix A��
Proof of the lemma� Let i� j be indices such that f�i � f�j� Thenfor any permutation �� the products P �f� � and P �f� �i�j are thesame �the notation is as in Fact ������ If � runs through all permu�tations� then also �i�j runs through all permutations �although ina somewhat di�erent order� and therefore we have
S�f �X�
sgn��i�jP �f� �i�j �X�
�sgn��P �f� � � �S�f�
hence S�f � � as the lemma claims�
By the lemma� we can write
det�AAT �X
f �f��������ng�f��������mgS�f�
where the summation is over all injective functions f�� �� � � � � ng��f�� �� � � � �mg�
�� A proof working with determinants ���
Our goal now is to show that the right�hand side of the last equa�tion equals
PI det�AI
�� where the sum runs over I � �f��������mgn
��
Let us choose some I � �f��������mgn
�� and calculate
det�AI� � det�AI det�A
TI � det�AIA
TI �
This determinant can be expanded in exactly the same manner aswe did for the determinant of AAT � This time we get
det�AIATI �
Xf �f��������ng�I
S�f�
We thus have
XI��f��������mgn
det�AI� �
XI��f��������mgn
Xf �f��������ng�I
S�f
�X
f �f��������ng�f��������mgS�f � det�AAT �
the second equality follows from the fact that any injective functionf � f�� �� � � � � ng��f�� �� � � � �mg uniquely determines the n�element setI of its values� This proves the Binet�Cauchy theorem ������ �
Let us mention a geometric interpretation of the Binet$Cauchy the�orem in terms of volumes� We omit all proofs� since these� althoughelementary� would lead us farther into geometry than we want to go inthis book� Let us consider an n�m matrix A as in the theorem� and letus interpret its n rows as n vectors a�� a�� � � � � an in the m�dimensionalspace Rm� These n vectors span an n�dimensional parallelotope P inRm� Fig� ��� illustrates this for m � � and n � � about the onlynontrivial case where a picture can be drawn� It can be shown thatj detAAT j is the square of the n�dimensional volume of P in the �g�ure� it is simply the squared area of P � Choosing an n�n submatrix Bcorresponds to projecting the vectors a�� a�� � � � � an to a n�dimensionalsubspace of Rm spanned by some n coordinate axes� In the �gure� thereare � possible � � � submatrices corresponding to the projections intothe � coordinate planes� The quantity j detBBT j is the squared volumeof the corresponding projection of P � and the Binet$Cauchy theoremasserts that the squared volume of P equals the sum of the squaredvolumes of the n�dimensional projections of P � Actually� for n � � andm � �� the reader may want to check that this is just the theorem ofPythagoras�
��� The number of spanning trees
P
Pxz
Pxy
Pyz
z
x
y
areaP � �areaPxy�
�areaPxz��areaPyz
�
Fig� ��� Illustration for the geometric meaning of the Binet$Cauchy the�
orem�
Exercises
�� In this exercise� G is a graph on n vertices� Q is its Laplace matrix�and Q� denotes the matrix whose element at position i� j equals��i�j detQij �
a Prove that detQ � �
b Prove that if the graph G is connected then its Laplace matrix hasrank n� ��c �Prove that the rank of the Laplace matrix of a disconnected graphis at most n � �� Derive that for a disconnected G� Q� is the zeromatrix�
d Show that if G is connected and x � Rn is an arbitrary vector� thenQx � holds if and only if x is a multiple of the vector �� �� � � � � ��
e �Prove that the product QQ� is a zero matrix� Using d� infer thatall the elements of the matrix Q� are identical�
�� Let G be a graph� which exceptionally� for the purposes of this ex�ercise may also contain loops and multiple edges� Let e be an edgethat is not a loop� De�ne G � e as G with the edge e deleted� andG � e as the graph arising from G by deleting the edge e and a sub�sequent gluing of the end�vertices of e into a single vertex� The otheredges are preserved� and so this operation can produce new loops ormultiple edges note that this is di�erent from the operation of edgecontraction introduced in Section ����
a Prove that T G � T G� e � T G � e�
�� A proof working with determinants ���
b Derive the number of spanning trees of the ��dimensional cubethis graph is drawn in Fig� ��� by a calculation based on part a�
c Find the number of spanning trees of the ��dimensional cube usingTheorem ������
�� Solve Exercise ����� using Theorem ������
�� �Calculate T Kn�m the number of spanning trees of the completebipartite graph�
�� �Let G be an undirected graph and M its incidence matrix� if G hasn vertices v�� v�� � � � � vn and m edges e�� e�� � � � � em thenM is an n�mmatrix with
mik �
�� if vi � ek otherwise�
Prove that the following two conditions are equivalent�
i G is bipartite�
ii Any square submatrix of M arising by deleting some rows andcolumns has determinant � �� or ��� A matrix M with this propertyis called totally unimodular�
�
Finite projective planes
Mathematicians are often interested in objects that are highly reg�ular in some sense� An good example is the regular Platonic solidswe have seen in Section ���� They are scarce� beautiful� and alsovery useful� For instance� symmetry groups related to them play animportant role in physics�
In this chapter� we will consider certain very regular families of ��nite sets� the so�called �nite projective planes� As the name suggests�this notion has a geometric inspiration� Finite projective planes arehighly symmetric and also somewhat rare� Appreciating their math�ematical usefulness� and maybe also their beauty� requires learningsomething about them �rst� Let us remark that the study of regularcon�gurations of sets with a avor somewhat similar to �nite pro�jective planes is an extensive branch of combinatorial mathematics�we will say a little more about such objects in Chapter ��� Suitablefurther reading for the present chapter is Van Lint and Wilson ����
��� De�nition and basic properties
A �nite projective plane is a system of subsets of a �nite set withcertain properties�
����� De�nition �Finite projective plane�� Let X be a �nite
set� and let L be a system of subsets of X� The pair �X�L is calleda �nite projective plane if it satis�es the following axioms�
�P�� There exists a ��element set F � X such that jL F j � �holds for each set L � L�
�P�� Any two distinct sets L�� L� � L intersect in exactly one
element� i�e� jL� L�j � ��
�P�� For any two distinct elements x�� x� � X� there exists exactly
one set L � L such that x� � L and x� � L�
��� De nition and basic properties ���
If �X�L is a �nite projective plane� we call the elements of Xpoints and the sets of L lines� If x � X is a point and L � L a lineand x � L� we say that �the point x lies on the line L� or also that�the line L passes through the point x� and similarly�
If we express the axioms �P���P� in this new language� theystart resembling familiar geometric statements� Axiom �P� says thatany two distinct lines meet at exactly one point �of course� in theusual planar geometry� this is not quite truethere is the exceptionof parallel lines�� Axiom �P� tells us that there is exactly one linepassing through any two distinct points� Axiom �P� then requiresthe existence of � points such that no � of them are collinear� Thisaxiom is of a somewhat auxiliary nature and it serves just for ex�cluding a few �degenerate� types of set systems that satisfy �P� and�P� but are rather uninteresting�
If a� b � X are two distinct points of a �nite projective plane�the unique line L � L containing both a and b will be denoted bythe symbol ab� If L�L� � L are distinct lines� the unique point ofL� L� is called their intersection �although� strictly speaking� theintersection of L� and L� in the usual sense is a one�point set�
Finite projective planes are a �nite analogy of the so�called pro�jective plane more exactly� real projective plane studied in geometry�The terminology introduced above �points�� �lines�� etc� follows thisanalogy� Thus� we make a short detour and mention what a real projec�tive plane is� First� we should perhaps remark that the adjective �real�indicates that the real projective plane is constructed from the set ofreal numbers� and not that the other kinds of projective planes wouldbe somehow faked�In the usual Euclidean plane� any two lines intersect at a single
point� but with an exception� parallel lines do not intersect at all� Inmany geometric considerations� such an exception is unpleasant� since itmay require treating many special cases� both in proofs and in analyticcalculations� The real projective plane is a suitable extension of theEuclidean plane by a set of additional points called the points at in�nity�Roughly speaking� each direction of lines in the plane corresponds
to one point at in�nity� and all the lines parallel to that direction arede�ned to intersect at this point� All the points at in�nity lie on a singleline at in�nity� In this way� one achieves that now every two distinctlines intersect at a single point which can lie at in�nity� of course� andhence all the axioms P�� P�� and P hold in the real projectiveplane�The points at in�nity are no philosophical mystery here� The pro�
jective plane is a mathematical construction of a similar kind as� for
��� Finite projective planes
example� producing rational numbers from the integers or real num�bers from the rationals� i�e� a kind of completion� Readers interestedin a detailed construction of the real projective plane will �nd it inSection ����We still owe the reader an explanation of the adjective �projective�
in the term projective plane� First� we should indicate what is a pro�jective transform� Consider two planes � and � in the ��dimensionalEuclidean space and a point c lying neither on � nor on �� and projecteach point of � from the point c into the plane �� This de�nes a map�ping� called a projective transform� of � into �� Or does it� Well� notquite� if x � � is a point such that the segment cx is parallel to the plane� then� in the usual Euclidean geometry� the image of x is unde�ned�But if we complement both � and � by lines at in�nity so that theybecome projective planes� then this projective transform is a bijectionbetween these two projective planes� If both � and � are consideredas copies of the same plane� we can regard this mapping as a bijec�tive mapping of the projective plane onto itself� The projective planeis thus an appropriate domain for doing projective geometry� a branchof geometry concerned with properties of geometric objects and con��gurations that are preserved by projective transforms� For example�projective transforms map conic sections circles� ellipses� hyperbolas�and parabolas to conic sections� but an ellipse can be transformed toa hyperbola etc�� and an elegant uni�ed theory of conic sections can bebuilt in the projective geometry�The analogy of the �nite projective planes with the real projec�
tive plane is useful as a motivation for various notions� and often alsofor intuition we can draw geometric pictures� Geometric considera�tions made in the real projective plane and using axioms P � P��and P� only can be carried out in �nite projective planes as well� Itshould not be forgotten� though� that a �nite projective plane is onlya system of �nite sets with properties P $P� and nothing else� andhence other geometric notions cannot be transferred to it automatically�For instance� there is no good notion of distance in a �nite projectiveplane� and hence it is not clear what a �circle� should mean� Anotherimportant di�erence is that in the �usual� geometric plane� the pointsof each line are naturally ordered �along� that line� but no such orderingcan be reasonably introduced in �nite projective planes�
As was remarked above� �nite projective planes are rare creatures�and� given only the de�nition� it is not easy to discover any exampleat all �try it if you don�t believe� Even the smallest example isinteresting�
����� Example� The smallest possible example of a �nite projectiveplane has � points and � lines� each line with � points� and it is called
��� De nition and basic properties ���
� � �
�
�
�
�
a
b
c
d
ef
g
Fig� �� The Fano plane�
the Fano plane� It is shown in Fig� ���� the points are marked bydots labeled ���� and the three points of each line are connected bya segment� in one case by a circle arc�� These connecting lines arelabeled by a�g in the �gure�
The Fano plane� although small� is a useful mathematical object seeSection ��� for one application� and it can also appear as a solution tovarious puzzles or even totally serious problems� such as the followingone� Seven policemen were transferred to the ��th precinct from variousdistricts� A good opportunity for them to get acquainted with eachother is to watch the Plano Bar on Southwest C Drive� which otherwiseis a simple and somewhat boring duty as the bar�s patrons are mostlycomputer criminals� digital money counterfeiters� and the like� A shiftof three men is required for that service� seven days a week� How can aweekly schedule of shifts be arranged in such a way that every two ofthe seven men have a common shift� The Fano plane provides a goodsolution points correspond to policemen and the shifts are the lines�arranged in some order� see Fig� ���� Everyone has the same numberof shifts� no one has more than two consecutive days� but on the otherhand� every shift has one man who was also present the previous dayand knows what was going on� etc�� We are not aware of such a scheduleactually being used by police forces� but� for instance� some motorcycleraces are organized according to a scheme based on an a�ne plane oforder � an a�ne plane is a concept closely related to projective planes�see Exercise � for a de�nition�
�It can be shown that � points cannot be drawn in the Euclidean plane insuch a way that each triple corresponding to a line in the Fano plane lies on aEuclidean straight line�see Exercise �
�A quiz for a�cionado of classical detective stories� can you recall where theseven policemen in Fig� ��� come from� and the names of their more famous rivalsor partners� the great detectives�
��� Finite projective planes
Weekly schedule for location� Plano Bar
Mon Cramer Hoong Japp
Tue Cramer Holcomb Lestrade
Wed Holcomb Hoong Janvier
Thu Cramer Janvier Parker
Fri Holcomb Japp Parker
Sat Janvier Japp Lestrade
Sun Hoong Lestrade Parker
O�cer�s signature�
Fig� �� Allocating � persons to � shifts by ��
We now prove several propositions showing that in a constructionof a �nite projective plane� our freedom is much more restricted thanmight appear at �rst sight�
����� Proposition� Let �X�L be a �nite projective plane� Then
all its lines have the same number of points� that is� jLj � jL�j forany two lines L�L� � L�
Proof� Choose two lines L�L� � L arbitrarily� First we prove anauxiliary claim� There exists a point z � X lying neither on L nor
on L��Proof of the auxiliary claim� Consider a set F � X as in the axiom�P�� We have jLF j � � and jL� F j � �� If F is not contained inL�L� we are done� The only remaining possibility is that L intersectsF at � points �call them a� b and L� intersects F at the � remainingpoints �denote them by c� d� Then we consider the lines L� � acand L� � bd� Let z be the intersection of L� and L��
The following geometric picture illustrates the situation�
abL
L� c d
zL�L�
��� De nition and basic properties ���
Of course� we have to be very careful to use only conditions P $P��rather than some extra geometric information from the picture� In manyrespects� �nite projective planes �look� quite di�erent to the geometricEuclidean plane�
We assert that z � L�L�� The lines L and L� intersect at a singlepoint� namely at a� and so if z � L� we would get z � a� But this isimpossible since then the line L� would contain the points z � a� b�and d� which are � points of F � This is forbidden by the condition�P�� Therefore z � L� and analogously one can show that z � L��This �nishes the proof of the auxiliary claim�
Now we show that the lines L and L� have the same size� To thisend� we de�ne a mapping ��L � L�� it will turn out that it is abijection� We �x a point z � L � L� and de�ne the image ��x ofa point x � L as the intersection of the lines zx and L�� as in thefollowing picture�
LL�
zx �x
By axioms �P� and �P�� the point ��x is well de�ned� Next� wecheck that � is a bijection� If y � L� is an arbitrary point� we considerthe line zy� and let x be its intersection with the line L� Then thelines zy and zx coincide� and hence we have y � ��x� The mapping� is a bijection as claimed and so jLj � jL�j� �
����� De�nition �Order of a projective plane�� The order of a�nite projective plane �X�L is the number jLj � �� where L � L is
a line �according to the proposition just proved� the order doesn�tdepend on the choice of the line L��
For example� the Fano plane has order � �the lines have � points�and it can be shown that it is the only projective plane of order � �upto renaming of the points� i�e� up to an isomorphism� Subtracting �from the line size in the de�nition of the order may seem odd� butthis de�nition of order is very natural in other connections� e�g� fora�ne planes �Exercise �� or for Latin squares �Section ����
We continue proving properties of �nite projective planes�
��� Finite projective planes
����� Proposition� Let �X�L be a projective plane of order n�Then we have
�i� Exactly n% � lines pass through each point of X�
�ii� jXj � n� % n% ��
�iii� jLj � n� % n% ��
Proof of �i�� Consider an arbitrary point x � X� First we observethat there exists a line L that doesn�t contain x� That is� if F is the��point con�guration as in �P� and a� b� c � F are points distinctfrom x� then at least one of the lines ab and ac doesn�t contain x� asis very easy to check�
Fix such a line L� x � L� For each point y � L� we consider theline xy� these are n% � lines passing through x� On the other hand�any line containing x intersects L at some point y � L and hence it iscounted among the above�mentioned n% � lines� Therefore� exactlyn% � lines pass through x�
Proof of �ii�� We choose some L � fx�� x�� x�� � � � � xng � L and apoint a � L� as in the following picture�
a
xn
x�x�
x�
� � �
L�
L�
L�
LnL
Let Li denote the line axi� i � �� �� � � � � n� According to �P�� any twoof these lines� Li and Lj� intersect at a single point� and this is thepoint a� The lines L�� L�� � � � � Ln each have n more points besides a�and hence they together contain �n% �n% � � n� % n% � distinctpoints� It remains to show that any point x � X n fag already lieson some of the lines Li� By �P�� the line ax intersects the line L atsome point� xi� and by �P�� the line ax must thus coincide with L�This proves part �ii�
We omit the proof of part �iii for now� In the sequel� we willlearn an important principle� and from it we will see that �iii followsimmediately from what we have already proved� �
Duality� The meaning of duality in projective planes is �exchangingthe roles of points and lines�� In order to formulate this exactly� we�rst introduce the so�called incidence graph of a �nite projective
��� De nition and basic properties ���
� � �
�
�
�
�
a
b
c
d
ef
g
� � � � � � �
a b c d e f g
Fig� �� The Fano plane and its incidence graph�
plane� In fact� the incidence graph can be de�ned for an arbitrarysystem S of subsets of a set X� The incidence graph is a bipartitegraph with vertex set X � S� where each set S � S is connectedby an edge to all points x � S� Consequently� each point x � X isconnected to all the sets containing it� Brie y� we can say that theedges of the incidence graph correspond to the membership relation���� The incidence graph of the Fano plane is shown in Fig� ���� thevertices are labeled by the labels of the corresponding points andlines� �By the way� the resulting graph is a pretty and importantgraph� although the drawing in our �gure is rather ugly� and it evenhas a name� the Heawood graph�
Given a �nite projective plane �X�L� the dual of �X�L is ob�tained by taking the incidence graph of �X�L and interpreting aslines the vertices that were understood as points� and conversely�vertices that used to be sets start playing the role of points� InFig� ���� we could just ip the graph upside down� Hence L is nowthought of as a point set� and for each point x � X� the set of linesfL � L� x � Lg is interpreted as a line� For the Fano plane example�the points of the dual are thus fa� b� � � � � gg� and the lines of the dualare fa� c� eg �for the point � in the Fano plane� fa� d� gg �for thepoint �� and so on�
Proposition� The dual of a �nite projective plane is itself a �nite
projective plane�
Proof� Let �X�L be a �nite projective plane� The dual of �X�Lis a pair �L�-� where - is a system of subsets of L� each of thesesubsets corresponding to some point of X� �Note that distinct pointsalways yield distinct subsets of L� since two points share only oneline�
��� Finite projective planes
We have to verify conditions �P���P� for �L�-� We begin withthe condition �P�� If this condition is translated into the languageof the original set system �X�L� it means that we should �nd � linesL�� L�� L�� L� � L such that no � of them have a point in common� Tothis end� let us consider a ��point con�guration F � fa� b� c� dg � Xas in the condition �P�� and de�ne L� � ab� L� � cd� L� � ad�L� � bc� If we look at any � of these � lines� any two of them shareone point of F � and this point is not contained in the third one�Hence any � of the lines L�� � � � � L� have an empty intersection� andwe have con�rmed the validity of the condition �P� for the dual setsystem�
The condition �P� formulated for the dual �L�- requires the fol�lowing� if x� x� � X are two distinct points� then there exists exactlyone line L � L containing both x and x�� This is exactly condition�P� for �X�L� Similarly� we �nd that �P� for the dual is a conse�quence of �P� for the original projective plane �X�L� �
Now we can call the dual of a �nite projective plane the dual
projective plane� Proposition ������i implies that the dual projectiveplane has the same order as the projective plane we started with�Also� one can see that parts �ii and �iii of Proposition ����� aredual to each other� and if we prove one of them� the other one mustbe valid too�
In general� if we have some valid statement about �nite projectiveplanes of order n� and if we interchange the words �point� and �line�everywhere in it� we get a valid statement again� To get a meaningfulsentence� we may have to rephrase other parts as well� For instance�if the original statement said �lines L�� L� intersect at the point x��we should say �points x�� x� are connected by the line L� in the dualstatement etc� Hence� we have a �recipe for producing new theorems�which gives us about half of the theorems in projective geometry forfree� It is sometimes called the duality principle� and it was noted bygeometers studying the real projective plane a long time ago�
Exercises
�� Prove that the Fano plane is the only projective plane of order � i�e�any projective plane of order � is isomorphic to it�de�ne an isomor�phism of set systems �rst�
�� �Construct a projective plane of order � before reading the next sec�tion��
��� De nition and basic properties ���
�� a Find an example of a set system X�L on a nonempty �nite setX that satis�es conditions P� and P� but doesn�t satisfy P �
b Find an X and L as in a such that jX j � � jLj � � and eachL � L has at least � points�c �Describe all set systems X�L as in a�
�� Let X be a �nite set and let L be a system of subsets of X satisfyingconditions P�� P�� and the following condition P ��
There exist at least two distinct lines L�� L� � L having at least� points each�
Prove that any such X�L is a �nite projective plane��� Prove part iii of Proposition ����� directly� without using duality�
�� Show that the number of sets in a set system consisting of ��elementsets on a ��point set� such that no two sets share more than one point�is at most ��� �Find an example with �� sets�
�� �Is it possible to arrange � bus routes in a city so that
i if any single route is removed doesn�t operate� say then any stopcan still be reached from any other stop� with at most one change� and
ii if any two routes are removed� then the network becomes discon�nected�
�� �Let X be a set with n��n�� elements� n �� and let L be a systemconsisting of n� � n� � subsets of X of size n� � each� Suppose thatany two distinct sets of L intersect in at most one point� The goal is toprove that X�L is a �nite projective plane of order n� The followingsequence of auxiliary statements give one possible way of arrangingthe proof�
a Prove that each pair or points of X is contained in exactly one setof L use double�counting�b Prove that at most n� � sets contain any given point�
c Prove that each point is contained in exactly n� � sets�
d Prove that any two sets of L intersect�e Verify that X�L is a projective plane of order n�
�� �Let X�L be a projective plane of order n� and let A � X be a setwith no � points lying on a common line� Prove that jAj � n� � forn odd� it can even be shown that jAj � n� ��
� � A�ne planes Let us de�ne an a�ne plane as a pair X�A� where Xis a set and A is a collection of subsets of X called lines satisfyingthe following axioms� there exist � points not contained in a commonline� any two distinct points are contained in exactly one line� and for
�� Finite projective planes
any point p and line A � A with p �� A� there exists exactly one lineA� with A� � A � and p � A��
a Check that the axioms of an a�ne plane are valid for the usualEuclidean plane� Find out how to construct a �nite a�ne plane froma �nite projective plane�
b De�ne relation k on A by letting A� k A� if and only if A��A� � �Prove that k is an equivalence�c �Analogously to our treatment of projective planes� prove that alllines in a �nite a�ne plane have the same cardinality n� and that suchan a�ne plane has n��n lines and n� points� with n�� lines passingthrough each point�
d �Show that from any a�ne plane of order n� one can construct aprojective plane of order n�
��� Show that the Fano plane cannot be embedded into the Euclideanplane� That is� there exist no � points and � lines in the Euclideanplane such that each pair of the points lies on one of the lines and eachpair of the lines intersects at one of the points� Use Exercise ������
��� Existence of �nite projective planes
Projective planes of orders �� �� �� and � exist� But there is no projec�tive plane of order �� �Proving this is not easy� see e�g� Van Lint andWilson ���� Projective planes of orders �� �� � again exist� but noneof order ��� Is there any regularity in this� Well� a projective plane oforder n exists whenever a �eld with n elements exists� Here a �eld ismeant in the algebraic sense� that is� it is a set with operations of ad�dition� subtraction� multiplication� and division that satisfy certainaxiomscheck the Appendix if you are not sure about the de�nition�As algebra teaches us� an n�element �eld exists if and only if n is apower of a prime number� This means� in particular� that projectiveplanes of arbitrarily large orders exist�
For an n divisible by at least two distinct primes� no n�element�eld exists� but nevertheless it is not known whether a projectiveplane of order n may exist in some such cases or not� There are somepartial negative results� for instance� if the number n divided by �gives remainder � or � and it cannot be written as a sum of twosquares of integers then no projective plane of order n exists �thisis not an easy theorem� This rules out the existence of a projectiveplane of order �� and of many other orders� but it doesn�t by farcover all possible orders� For instance� it says nothing about ordersn � �� ��� or ���
��� Existence of nite projective planes ���
The existence of projective planes of orders � and �� has alsobeen excluded� These results have an interesting history� For or�der �� a proof was already attempted by Euler� but only Tarry gavea convincing argument around ����� For order ��� a proof was donerecently using enormous computer calculations� For the next higherorder� ��� the existence of a projective plane remains an open prob�lem� It is clear that this problem can be solved by checking a �nitenumber of con�gurations� but the number of con�gurations seems tobe too gigantic for contemporary computing technology�
An algebraic construction of a projective plane� For readerswith an interest in the subject and with a little background in intro�ductory algebra� we explain how to construct a projective plane from a�eld� We are particularly interested in �nite projective planes� but theconstruction works in exactly the same way for the real projective planeand� in general� for any �eld�The construction starts with some �eld K� For the real projective
plane i�e� a suitable extension of the usual Euclidean plane by pointsat in�nity� we take the �eld R of all real numbers for K� If we choosean n�element �eld for K� the construction results in a �nite projectiveplane of order n� Our running example will be the ��element �eld K�i�e� the set f � �� �g with arithmetic operations modulo ��First we consider the set T � K� n f � � g� that is� the set of all
ordered triples x� y� t where x� y� t � K and x� y� t are not all simulta�neously equal to � On this T � we de�ne an equivalence relation � asfollows� x�� y�� t� � x�� y�� t� if and only if a nonzero � � K existssuch that x� � �x�� y� � �y�� and t� � �t� it is not at all di�cultto check that this is indeed an equivalence� Points of the constructedprojective plane are the classes of this equivalence� The projective planethus produced� is usually denoted by PK� in the literature� where onemay write the speci�c �eld being used instead of K� For instance� thereal projective plane is usually denoted by PR��In order to gain a better intuition about the projective plane� we se�
lect one representative triple from each class of the equivalence �� Forthese representatives� we choose the triples whose last nonzero compo�nent equals �� Hence� the representatives are triples of the types x� y� ��x� �� for some x� y � K� and the triple �� � � It is easy to con�vince oneself that any other triple is equivalent to a triple of the above�
�For a �nite �eld� we haven�t yet proved that we obtain a �nite projectiveplane in the sense of De�nition �� � � and we haven�t even de�ned what the linesare� so strictly speaking� we shouldn�t yet call the object being constructed aprojective plane� But� being �hopefully� among friends� there is no reason forsuch a total strictness� is there�
��� Finite projective planes
mentioned form� and also that no two of the triples chosen as represen�tatives are equivalent under ��It would be cumbersome to keep speaking about equivalence classes
all the time� Thus� we will say �a point x� y� t� in the sequel� meaningthe whole equivalence class containing x� y� t�IfK is an n�element �eld� we can now count how many points we ob�
tain� The number of points of the form x� y� � is n�� there are n pointsof the form x� �� � and� moreover� we have the one point �� � �altogether n� � n � � as it should be� For n � �� all the points withtheir labels are drawn in the following diagram�
�
� � �� ��
The points with the last coordinate equal to � are arranged into anatural �� � grid pattern�Now it is time to de�ne the lines� For each triple a� b� c � K� n
f � � g� we de�ne a line La� b� c as the set of all points x� y� t ofour projective plane satisfying the equation
ax� by � ct � � ���
Obviously� two equivalent triples x� y� t and �x� �y� �t either bothsatisfy this equation or none does� and hence we have indeed de�ned acertain set of points of the projective plane� Also� one can see that forall nonzero � � K� the triples �a� �b� �c de�ne the same line as thetriple a� b� c� Hence� on the triples that de�ne lines we have exactlythe same equivalence relation as on the triples that de�ne points� Wecan select the same representative triples as we did for the points� i�e�triples whose last nonzero component is �� In the following picture� wehave drawn all the lines passing through the point � � � labeled bytheir representative triples� We have omitted the labels of most of thepoints they are as in the preceding diagram�
�
� � �� ��
In order to show that for an n�element �eld� we have really con�structed a �nite projective plane of order n� we must check conditions
��� Existence of nite projective planes ���
P $P�� We begin with the condition P� any two distinct lines in�tersect at a single point� So let a�� b�� c� and a�� b�� c� be two triplesthat are not equivalent� i�e� one is not a multiple of the other�We could now directly calculate the point of intersection of the two
considered lines this is a solution of a small system of linear equationsand verify its uniqueness� We give another proof relying on some basicresults of linear algebra� A reader who tries to do the proof by a directcalculation may gain a certain new appreciation of linear algebra�Let us regard the triples a�� b�� c� and a�� b�� c� as ��dimensional
vectors over the �eld K� Both are nonzero vectors� and the fact that oneis not a multiple of the other means that they are linearly independent�Hence� the matrix �
a� b� c�a� b� c�
�has rank � linear independence and rank are over the �eld K� Letus now view the columns of this matrix as ��dimensional vectors� Weknow that � vectors in a ��dimensional space must necessarily be linearlydependent� which means that there exist � numbers x� y� t � K� not allof them simultaneously � and such that
xa�� a� � yb�� b� � tc�� c� � � � ���
If we rewrite this for each coordinate separately� we obtain that thepoint x� y� t lies on both the considered lines�On the other hand� since the rank of the considered matrix is �� two
linearly independent columns have to exist� Suppose� for instance� thatthey are a�� a� and b�� b�� This means that for any vector u� v� theequation xa�� a� � yb�� b� � u� v has a unique solution� In otherwords� if we prescribe the value of t in Eq� ���� the values of x and yare already determined uniquely� and so all solutions to this equationare multiples of a single vector� This means that the two consideredlines intersect at a single point�This argument can be expressed in a somewhat more learned and
more concise way� The linear mapping sending a vector x� y� t � K�
to the vector xa�� a� � yb�� b� � tc�� c� � K� has rank �� hence itis onto and its kernel is ��dimensional�We have proved P�� The condition P� could be proved in a simi�
lar way� or we can say right away that the roles of the triples a� b� c andx� y� z in Eq� ��� are completely symmetric� and so we have againa duality between lines and points� Finally� veri�cation of the conditionP is left to the reader� �
Remarks� The construction presented above might give the impressionthat some points of the projective plane are somewhat special� di�erentfrom the others� This is not so� no points have any special signi�cance�
��� Finite projective planes
Fig� �� The real projective plane in moonlight�
and the �in�nity� can in some sense be imagined wherever convenient�the projective plane looks �locally everywhere the same��For the real projective plane� a point x� y� � in the above construc�
tion is usually identi�ed with the point x� y of the Euclidean plane�Points whose third coordinate is are the points at in�nity� In otherwords� a triple x� y� t with t �� corresponds to the �Euclidean� pointxt �
yt � Each point at in�nity� x� �� or �� � � corresponds to one
direction of lines in the Euclidean plane� Points at in�nity can be imag�ined as points �on the horizon� in a drawing of the Euclidean plane inperspective� see Fig� ���� where circles correspond to points with integercoordinates�
Exercises
�� In the literature� the points of the real projective plane PR� are of�ten identi�ed with the lines in the ��dimensional Euclidean space R�
passing through the origin of coordinates� With the knowledge of thealgebraic construction of PR� described in this section� can you ex�plain why� �Would you know how to de�ne lines of the projectiveplane in this geometric interpretation� And how would you embed theEuclidean plane into the projective plane in this situation�
�� ���CS Prove the nonexistence of a projective plane of order �� Write acomputer program for checking and excluding all con�gurations com�ing into consideration� One has to proceed cleverly� since searchingall systems of �� seventuples on �� points would take way too long�Clever proofs are known that do not need any case analysis but theseare not easy to discover�
��� Orthogonal Latin squares ���
� � �
� � �
� � �
� � �
� � �
� � �
Fig� �� Two orthogonal Latin squares of order ��
��� Orthogonal Latin squares
A Latin square of order n is a square table with n rows and ncolumns� Each entry is a number from the set f�� �� � � � � ng� and eachnumber in this set occurs exactly once in each row and also in eachcolumn� Two � � Latin squares are depicted in Fig� ����
Now we say what it means when two Latin squares of the sameorder are orthogonal� Imagine that one of the squares is printed on atransparency and that we lay it over the other square in such a waythat the corresponding entries lie above one another� For example�the squares from Fig� ��� overlaid produce
��
��
��
��
��
��
��
��
��
In this way� we get n� ordered pairs� each pair being formed by anentry of the square on the transparency and the corresponding entryof the underlying square� The considered squares are orthogonal if noordered pair appears twice� Since the number of all possible orderedpairs of numbers from � to n is n� too� each pair has to appearexactly once�
����� Theorem� Let M be a set of Latin squares of order n� suchthat each two of them are orthogonal� Then jM j � n� ��
Proof� We begin with the following observation� Let A and B beorthogonal Latin squares of order n� and let � be some permutationof the numbers �� �� � � � � n� Let us make a new Latin square A�� whoseentry at position �i� j is the number ��aij� where aij is the entry atposition �i� j of the square A� By the de�nition of orthogonality� it isnot hard to see that A� and B are also orthogonal Latin squares� This
��� Finite projective planes
observation can be summarized by the phrase �the orthogonality ofLatin squares doesn�t change by renaming the symbols in one ofthem���
To prove the theorem� imagine we have Latin squares A�� A��� � � �At� each two of them being orthogonal� For each Ai� permute itssymbols �i�e� the numbers ����� � � �n in such a way that the �rst rowof the resulting Latin square A�i is ��� �� � � � � n� By the above ob�servation� the Latin squares A��� � � � � A
�t are still pairwise orthogonal�
Let us look at which numbers can occupy the position ��� � of thesquare A�i� First of all� this entry must not be �� because the �rstcolumn already has a � in the �rst row� Further� no two squares A�iand A�j may have the same numbers at position ��� �� if they did� byoverlaying A�i and A�j we would get a pair of identical numbers� say�k� k� at the position ��� �� but this pair has already appeared atthe kth entry of the �rst row� Hence each of the numbers �� �� � � � � ncan only stand at the position ��� � in one of the A�i� and thereforet � n� �� �
A reader who has been wondering why we� suddenly� started talk�ing about Latin squares in a chapter on projective planes may per�haps be satis�ed by the next theorem�
����� Theorem� For any n � �� a projective plane of order n exists
if and only if there exists a collection of n� � mutually orthogonal
Latin squares of order n�
Proof of Theorem ����� We will not do it in detail� We only describehow to construct a projective plane from orthogonal Latin squares andvice versa� Given n�� orthogonal Latin squares S�� � � � � Sn�� of order n�we will produce a projective plane of order n�First we de�ne the point set X of the constructed plane� It has n��
points �at in�nity� denoted by r� c� and s�� s�� � � � � sn��� and n� points
i� j� i� j � �� �� � � � � n� Next� we introduce the lines in several steps�One line B � fr� c� s�� � � � � sn��g consists of the points �at in�nity��Then we have the n lines R�� R�� � � � � Rn� where
�In fact� one is not really obliged to �ll Latin squares only with numbers � �� � � � � n� Equally well� one can use n distinct letters� n di�erent kinds of Cognacglasses� and so on� This is also perhaps the appropriate place to touch the some�what puzzling question� why are Latin squares called Latin� It seems that insome traditional problems� the symbols written in the considered square tablesused to be Latin letters �while some other squares were �lled with Greek lettersand called�what else��Greek squares��
��� Orthogonal Latin squares ���
Ri � fr� i� �� i� �� � � � � i� ng�
and the n lines
Cj � fc� �� j� �� j� � � � � n� jg�
These are all drawn in the following picture for n � ��
r
����
��
��
r
��������
B
rs�
rs� c
R�rrr
r r r R�
R�rrrr
C� C� C�
The points and lines of the projective plane we have drawn andlabeled so far must look exactly the same in any projective plane oforder n we also haven�t yet used any information from the given n� �orthogonal Latin squares� The squares will now specify the lines of theprojective plane passing through the points s�� s�� � � � � sn�� besides theline B� As the chosen notation suggests� the Latin square Sk determinesthe lines passing through the point sk� If Skij denotes the entry of Skin the ith row and jth column� we de�ne the lines
Lkm � fskg � fi� j� Skij � mg
for m � �� �� � � � � n and k � �� �� � � � � n� �� For instance� if S� were theLatin square in Fig� ��� on the left� then the line L�� corresponding tothe number � in the square would be L�� � fs�� �� �� �� �� �� �g�This �nishes the description of the �nite projective plane corre�
sponding to the collection of n�� orthogonal Latin squares� It remainsto verify the axioms of the projective plane� It is easy to calculate thatthe total number of both lines and points is n��n��� By Exercise ������it is now su�cient to check that any two lines intersect in at most onepoint� For this� one has to use both the facts that each Sk is a Latinsquare and that any two of the Latin squares are orthogonal� We leavethis as an exercise�To prove the equivalence in Theorem ������ we should also show how
to construct n� � orthogonal Latin squares from a projective plane oforder n� This construction follows the same scheme as the converse one�In the projective plane� we choose two distinct points r and c arbitrarily�and we �x the notation further as in the above construction� Then the
��� Finite projective planes
kth Latin square Sk is �lled out according to the lines passing throughthe point sk� So much for the proof of Theorem ������ �
Remark� The proof actually becomes more natural when it is done with�nite a�ne planes see Exercise ����� �
Exercises
�� Go through the construction in the proof of Theorem ����� for n � �when only one Latin square exists� up to a permutation of the num�bers� Check that we obtain the Fano plane in this way�
�� Verify that any two lines constructed in the proof of Theorem �����intersect in at most one point do not forget the lines Ri and Cj ��Distinguish where one uses the de�nition of a Latin square and wherethe orthogonality�
�� Show that the construction sketched at the end of the proof of Theo�rem ����� indeed produces n� � orthogonal Latin squares�
�� De�ne a liberated square of order n as an n � n table with entriesbelonging to the set f�� �� � � � � ng� Orthogonality of liberated squaresis de�ned in the same way as for Latin squares� For a given number t�consider the following two conditions�
i There exist t mutually orthogonal Latin squares of order n�
ii There exist t�� mutually orthogonal liberated squares of order n�
a Prove that i implies ii�
b �Prove that ii implies i�
�� Let T be a �nite �eld with n elements� Denote its elements by t��t�� � � � � tn��� where t� � and t� � �� For k � �� �� � � � � n� �� de�nean n � n matrix S�k�� where the entry of the matrix S�k� at positioni� j equals titk � tj the multiplication and addition in this formulaare in the �eld T � Prove that S���� S���� � � � � S�n��� is a collection ofmutually orthogonal Latin squares of order n� Using Theorem ������this gives an alternative construction of a projective plane of order n�
�� For natural numbers m � n� we de�ne a Latin m � n rectangle as arectangular table with m rows and n columns with entries chosen fromthe set f�� �� � � � � ng and such that no row or column contains the samenumber twice� Count the number of all possible Latin ��n rectangles�
��� Combinatorial applications
In combinatorial mathematics� �nite projective planes often serve asexamples of set systems with various remarkable properties� One can
��� Combinatorial applications ���
say that if we have some hypothesis about �nite set systems and lookfor a counterexample to it� or if we want an example of a set systemwith some prescribed properties� then it may be a good idea to trya �nite projective plane among the �rst candidates�
Trying to document the usefulness of projective planes in math�ematics and its applications resembles explaining the usefulness ofnoodles� say� in the kitchen� Certainly one can do lots of great cookingwithout them� Wonderful foods can also be prepared from noodles�but it�s a question of a good recipe �and cook and of adding varioussubtle ingredients� spices� etc� Noodles by themselves probably seemexciting to specialists only� Here we haven�t accumulated enoughmathematical ingredients and spices to prepare a nice but compli�cated recipe�example� and so we will o�er two simple combinatorialdishes only�
Just at the time this section was being written� newspapers reportedon the �rst Swiss bank to introduce on�line banking over the Internetin the US� it had been around for more than a year� Of course� safetyof the information being interchanged over the public network is of ut�most importance in such a case� The supposedly indecipherable codesby which the banks expect to achieve safety� are based on the so�calledelliptic curves over �nite �elds� The theory of elliptic curves has beendeveloped for a long time in number theory and algebraic geometry� tra�ditionally considered absolutely pure mathematics without any applica�bility whatsoever� And these elliptic curves are inhabitants or subsetsif you prefer of �nite projective planes� So it goes�The book by Koblitz �� � can serve both as an introduction to num�
ber theory and a gate to the world of mathematical cryptography� Butlet us return to our combinatorial applications�
Coloring set systems by two colors� Let X be a �nite set� andlet M be a system of subsets of X� We say that the set system Mis ��colorable if it is possible to color each of the points of X by oneof two given colors� say red or white� in such a way that each setM �M contains points of both colors ���colorablility is often calledproperty B in the literature�
For example� ifX � f�� �� �g andM � ff�� �g� f�� �g� f�� �gg thenM is not ��colorable� More generally� if all the sets ofM have exactly� elements� then we can regard �X�M as a graph� and here being��colorable means exactly the same thing as being bipartite� What if
�Software products using some of these codes are also subject to US exportrestrictions� just like high�tech weapons�
�� Finite projective planes
the sets of M have more than � points each� For instance� what canbe said if all the sets of M have exactly � points� It turns out thatthe situation with ��colorability becomes much more complicatedthan for graphs� For instance� the question of whether a given M is��colorable or not becomes algorithmically di�cult�
Let us consider the following natural question� what is the small�est number of sets of a set systemM consisting of ��point sets that isnot ��colorable� It turns out that the answer is �� and the Fano planeprovides one�half of this answer� it has � sets consisting of � pointseach� and it is not ��colorable �we leave a proof as Exercise �� And�in fact� it is the only set system with � triples that is not ��colorable�We will deal with the second half of the answer� i�e� methods forshowing that all systems with � or fewer triples are ��colorable� inSection ��� �Theorem ������
One could talk much longer about ��colorability� as it is a quiteimportant concept in combinatorics� but here we only wanted topoint out a little problem in this area where the projective planes�surprisingly� come into play�
More on graphs without K��� with many edges� Theorem �����tells us that if G is a graph on m vertices containing no K��� as
a subgraph� then G has at most ��
�m��� %m
�edges� Using �nite
projective planes� we show that this bound is nearly the best possiblein general�
����� Theorem� For in�nitely many values of m� there exists a
K����free graph on m vertices with at least ����m��� edges�
Proof� Take a projective plane of order n� and consider its incidencegraph �as in the part concerning duality in Section ���� The numberof vertices of this graph is m � ��n�%n%�� Each of the n�%n%�lines has n%� points� and this means that the total number of edges
is �n� % n% ��n% � � �n� % n% ���� ��m�
���� � ����m����What would it mean if the incidence graph contained a K��� as a
subgraph� Well� in the language of the projective plane� it would saythat there exist two points x� x� and two lines L�L� such that x � L�x� � L� x � L�� and x� � L�� This cannot happen in a projectiveplane� �
Remark� The constant ���� in Theorem ����� can still be improvedsomewhat� The optimal value is ���� see Exercise ��
��� Combinatorial applications ���
Exercises
�� Prove that the Fano plane is not ��colorable�
�� Better K����free graphs Let n be a prime power� and let K be ann�element �eld� Consider the equivalence classes of the equivalence re�lation � on the set of triplesK�nf � � g introduced in Section ����Let these classes be vertices of a graph G� and two vertices a� b� c andx� y� z are connected by an edge if and only if ax�by�cz � � Provethat
a the edges are well de�ned�
b �the graph G contains no K��� as a subgraph�
c each vertex has degree at least n� and
d if m � n��n�� denotes the number of vertices� then the numberof edges is at least �
�m��� �m�
�� Let G be a bipartite graph with both vertex classes of sizes n andcontaining no K��� as a subgraph�
a �By the method of Section ���� prove that G has at most
�
�n� �
p�n� �
edges�
b �Prove that such a G with precisely this number of edges exists ifand only if a projective plane of order q exists with n � q� � q � ��
�
Probability and probabilisticproofs
The reader will most likely know various problems about determiningthe probability of some event �several such problems are also scat�tered in the other chapters� Textbooks often contain such problemstaken �from real life�� or at least pretending to be real life problems�They speak about shu.ing and drawing cards� tossing coins or evenneedles� or also about of defunct lightbulbs� defunct phone lines� ordecaying radioactive atomsdepending on the author�s inclinationsand fantasy� In this chapter we want to show a remarkable mathe�matical application of probability� namely how mathematical state�ments can be proved using elementary probability theory� althoughthey don�t mention any probability or randomness�
Alon and Spencer ���� is an excellent book for studying proba�bilistic methods in combinatorics in more depth� and Grimmett andStirzaker ���� can be recommended as a probability theory textbook�
��� Proofs by counting
In two introductory examples� probability will not be mentioned� weuse a simple counting instead�
����� Example� Consider a new deck of �� cards �in such a deck�cards go in a certain �xed order� We will shu.e the cards by so�called dovetail shu ing� we divide the deck into two parts of equalsize� and we interleave the cards from one part with the cards fromthe other part� in such a way that the order of cards from each part isunchanged �see Fig� ���� We prove that if this procedure is repeatedat most � times� we cannot get all possible orderings of the cards� andhence � rounds of dovetail shu.ing certainly won�t yield a randomorder of the cards�
��� Proofs by counting ���
Fig� ��� Dovetail shu ing�
Proof� There are ��� possible orderings of the cards� We count howmany di�erent orderings can be obtained by the described shu.ingprocedure� How many ways are there to intermix the two separateparts of the deck �let us refer to them as the left part and the rightpart� If we know the ordering in both the left and the right parts�and if we specify which cards in the intermixed deck come from theleft part and which from the right part� we can already reconstructthe ordering of the deck after the parts are intermixed� Hence� afterthe �rst dividing and interleaving there are
����
�possible orderings�
and by � repetitions of this procedure we can thus obtain at most����
��orderings� A pocket calculator� or the estimates in Chapter ��
can tell us that this number is smaller than ���� and hence thereexists some ordering that cannot be obtained by � rounds of dovetailshu.ing� �
The result just proved doesn�t say that we could get all possibleorderings by � rounds� The question of how many random dovetailshu.es are needed to obtain an ordering reasonably close to a ran�dom one is considerably more di�cult� A very sophisticated paperon the subject is Bayer and Diaconis �����
Di�cult Boolean functions� A Boolean function of n variables is amapping f � f � �gn� f � �g� i�e� assigning either or � to each possiblecombination of n s and �s� Here � represents the logical value �true�and the logical value �false�� A Boolean function can be speci�ed bya table of values� but also in many other ways� For example� a computerprogram that reads n bits of input and computes a YES�NO answer de��nes a certain Boolean function of n variables� Similarly� an integratedcircuit with n input wires and one output wire de�nes a Boolean func�tion of n variables� assuming that the inputs and the output each haveonly two possible states�
��� Probability and probabilistic proofs
We want to show that there exist Boolean functions that require avery large description� i�e� a very long program� or a circuit with a hugenumber of components� etc� Technically� this is probably simplest to dofor yet another way of describing Boolean functions� namely by logicalformulas�The reader may know logical formulas from predicate calculus� say�
A logical formula in n variables is a string made up of symbols x��x�� � � � � xn for the variables each of them can be repeated several times�parentheses� and the following symbols for the logical connectives� !conjunction� " disjunction� � implication� � equivalence� and# negation� Not every sequence of these symbols is a logical formula� ofcourse� a formula has to satisfy simple syntactical rules� such as properparenthesizing etc� The details of these rules are not important for ushere� One possible formula in � variables is� for example� x�!x�"x�!#x�� Each logical formula in n variables de�nes a Boolean function ofn variables� for given values of the variables x�� x�� � � � � xn� substitutethese values into the formula and evaluate the truth value of the formulaby the rules for the various connectives� For example� we have ! � ! � � �! � and �! � � �� and so on� It is not too di�cult to showthat any Boolean function can be de�ned by a formula� The questionnow is� how long does such a formula have to be�We show
����� Proposition� There exists a Boolean function of n variables thatcannot be de ned by any formula with fewer than �n� log�n�� symbols� For example� for �� variables we may already need a formula withmore than a million symbols�
Proof� The number of all Boolean functions of n variables is ��n
� whilethe number of formulas in n variables written by at most m symbols isno more than n��m� because each of the m positions in the formulacan be �lled in by one of the n � � possible symbols� or maybe bya space� In this way� we have also counted lots of nonsense strings ofsymbols� but a rough upper bound is fully su�cient� If ��
n
� n��m�there exists a Boolean function that cannot be expressed by a formulawith at most m symbols� By taking logarithms in the inequality� we getm �n� log�n� �� �
Similarly� one may consider Boolean functions de�ned by computerprograms in some �xed programming language� or by integrated circuitsconsisting of some given set of components� and so on� In each such case�a counting similar to the above proof shows the existence of functions ofn variables that cannot be de�ned by a program or circuit of size smallerthan roughly �n� We did the proof for formulas since their de�nitionand counting seems simplest�
��� Proofs by counting ���
The two examples just given have a common scheme� We have aset of objects� and we want to show that there exists some �good�object among them �with some required property� in Example ������good objects were card orderings unattainable by � dovetail shu.es�We count how many objects there are in total� and we upper�boundthe number of bad objects� If we can show that the number of badobjects is smaller than the number of all objects� this means thatsome good object has to exist� Typically� we even show that most ofthe objects must be good�
A remarkable feature of this method is that we do not construct anyparticular good object� and we don�t even learn anything about what itmight look like�we only know that it exists� In Example ������ we haveshown that some ordering of cards cannot be obtained� but we have notexhibited any speci�c such ordering� In the proof of Proposition �����we have not found out how to get a �di�cult� Boolean function withno short formula� This situation is quite usual for proofs of this type�It might look fairly paradoxical� since we are usually in the situation ofsearching for a piece of hay in a haystack with at most a few needlesin it� i�e� we can prove that a large majority of the objects are good�But avoiding the needles proves enormously hard in many situations�For many interesting combinatorial objects� there are relatively easyexistence proofs but none or only very di�cult explicit constructionsare known�
The argument about good and bad objects can be reformulatedin the language of probability� Imagine that we choose an objectfrom the considered set at random� If we show that with a nonzeroprobability� we choose a good object� this means that at least onegood object must exist� In more complicated problems� the languageof probability becomes simpler than counting the objects� and onecan apply various more advanced results of probability theory whoseformulation in terms of object counting would be immensely cum�bersome� We will use the language of probability in the subsequentexample� Any reader who should feel uneasy about some of the no�tions from probability theory can �rst read the next section�
Twocoloring revisited� Let X be a �nite set and let M be asystem of subsets of X� From Section ���� we recall the de�nition of��colorability� we say thatM is ��colorable if each of the points of Xcan be colored either red or white in such a way that no set ofM hasall points red or all points white� Here we will discuss the followingproblem �a particular case has been considered in Section ����
��� Probability and probabilistic proofs
����� Problem� Suppose that each set ofM has exactly k elements�What is the smallest number� m�k� of sets in a system M that isnot ��colorable�
It is easy to �nd out thatm�� � �� since we need � edges to makea graph that is not bipartite� But the question for k � � is alreadymuch more di�cult� In Section ���� we met a system of � triples thatis not ��colorable� namely the Fano plane� and so m�� � �� In fact�m�� � �� to prove this� we have to show that all systems with � orfewer triples can be ��colored� We begin with a general statementwhich gives a weaker bound for k � �� Then� with some more e�ort�we will improve the result for the particular case k � ��
����� Theorem� We have m�k � �k��� i�e� any system consisting
of fewer than �k�� sets of size k admits a ��coloring�
Proof� Let M be a system of k�element subsets of some set X� andlet jMj � m� We color each point of X red or white by the followingrandom procedure� For each point x � X� we toss a fair coin� If weget heads we color x white and if we get tails we color x red�
Let M � M be one of the k�tuples in the considered system�What is the probability that all the points of M get the same colorin a random coloring� The probability that all the k points are si�multaneously white is obviously ��k� and also the probability thatall the points of M turn out red is ��k� Altogether� the probability ofM ending up monochromatic is � ���k � ���k� Hence the probabilitythat at least one of the m sets in M is monochromatic is at mostm ���k� If this number is strictly smaller than �� i�e� if m � �k���then our random coloring is a ��coloring for the system M with anonzero probability� Hence� at least one ��coloring exists� De�nitelyand certainly� no probability is involved anymore� Theorem ����� isproved� �
How good is the bound on m�k in the theorem just proved� It isknown that for large k� the function m�k grows roughly as �k �moreexactly� we have m�k � *��kk��� and m�k � O��kk�� see �����and so the theorem gives quite a good idea about the behavior ofm�k� On the other hand� for k � � we only get the estimate m�k ��� which is still quite far from the correct value �� We improve thebound with two more tricks�
����� Theorem� m�� � ��
��� Proofs by counting ���
We have to show that any system of � triples on a �nite set Xis ��colorable� We distinguish two cases depending on the number ofpoints of X� jXj � � and jXj � �� Only the �rst case will be handledby a probabilistic argument�
Lemma� Let X be a set with at most � elements� and let M be a
system of at most � triples on X� Then M is ��colorable�
Proof� If needed� we add more points to X so that it has exactly� points� We choose � of these � points at random and color themwhite� and the remaining � points are colored red� Hence� we have��
�� �� possibilities for choosing such a coloring� If M is any triple
from M� there are only � among the possible colorings that leave Mmonochromatic� either M is colored red and the remaining � pointsare white� or M is white and the other points are red� Hence theprobability that M is monochromatic is �
�� � The probability thatsome of the � triples of M become monochromatic is thus no morethan
�� � �� and hence a ��coloring exists� �
The same proof shows that also any � triples on � points can be��colored�
For the second step� we need the following de�nition� Let X�M bea system of sets� and let x� y be two elements of X � We say that x andy are connected if there exists a set M �M containing both x and y� Ifx and y are points that are not connected� we de�ne a new set systemX ��M� arising by �gluing� x and y together� The points x and y arereplaced by a single point z� and we put z into all sets that previouslycontained either x or y� Written formally� X � � X n fx� yg � fzg�M� � fM � M� M � fx� yg � g � fM n fx� yg � fzg� M � M�M � fx� yg �� g�Let us note that if points x and y are not connected and M is a
system of triples� then X ��M� is again a system of triples� and theset X � has one point fewer than X � Further we claim that if X ��M�is �colorable then X�M is �colorable too� To see this� consider a��coloring of the set X �� and color X in the same way� where both xand y receive the color the �glued� point z had� It is easy to see that nomonochromatic set can arise in this way� Hence� for �nishing the proofof Theorem ������ it su�ces to prove the following�
Lemma� Let X�M be a system of � triples with jX j �� Then Xcontains two points that are not connected in M�
Proof� One triple M � M makes � pairs of points connected� Hence� triples yield at most � � � � �� connected pairs� But the total number
��� Probability and probabilistic proofs
of pairs of points on a ��element set is� �
�� ��� and hence some pair is
not connected even at least �� �
Let us remark that the exact value of m� is already unknown andsimilarly for all the larger k� It is also easy to see that m� can inprinciple be computed by considering �nitely many con�gurations sys�tems of ��tuples� But the number of con�gurations appears su�cientto resist the power of all kinds of supercomputers� at least if that poweris not accompanied by enough human ingenuity�
Exercises
�� a Prove that any Boolean function of n variables can be expressedby a logical formula�
b Show that the formula in a can be made of length at most Cn�n
for a suitable constant C� �Can you improve the order of magnitudeof this bound� say to O�n or even better�
�� a Prove that m� ��� i�e� that any system of �� fourtuples can be��colored� Proceed similarly as in the proof of Theorem ������ distin�guishing two cases according to the total number of points�
b �Give as good an upper bound on m� as you can� Can you getbelow � � Below � �
�� We have �� fair coins and one counterfeit coin� which looks like a faircoin but is a bit heavier� Show that one needs at least � weighings todetermine the counterfeit coin� We have no calibrated weights� and inone weighing we can only �nd out which of two groups of some k coinseach is heavier� assuming that if both groups consist of fair coins onlythe result is an equilibrium�
�� �In the following diagram� a train with n cars is standing on the railtrack labeled A� The cars are being moved to the track B� Each carmay or may not be shifted to some of the side tracks I$III but it shouldvisit each side track at most once and it should go through tracks Cand D only once�
A B
I II III
C D
Prove that if n is large enough then there is some order of the carsthat cannot be achieved on track B�
��� Finite probability spaces ���
��� Finite probability spaces
Now it is time to talk about the basic notions of mathematical prob�ability theory� We will restrict ourselves to things we will need forour examples� By no means do we intend to provide a substitute fora proper course in probability theory� Anyone educated in mathe�matics or in theoretical computer science should know considerablymore about probability than what is said here�
Probability is a notion that can appear both in mathematics andoutside it� �in real life�� �in practice�� or whatever else one can callthis� De�ning the �real� probability is di�cult� and it is a philosoph�ical problem� Mathematics avoids its solution� though� it constructs acertain model of the �real� probability� and this model is a purely math�ematical object� At its fundamental level� several simple properties ofprobability derived from knowledge about the real world are built inas axioms� such as the fact that the probability of some event occur�ring plus the probability of its not occurring add up to �� But oncethe axioms are accepted� one works with the mathematical notion ofprobability as with any other mathematical object� and all its proper�ties and all rules for calculating with probabilities are logically derivedfrom the axioms� This model is very useful and its predictions agreewith the behavior of probability in practice� but this doesn�t mean thatthe mathematical probability and the �real� probability are the samenotions� In the sequel� we will speak of probability in the mathemat�ical sense� but we will employ examples with �real� probability as amotivation of the notions and axioms�
A basic notion in probability theory is a probability space� Herewe restrict ourselves to �nite probability spaces�
����� De�nition� By a �nite probability space we understand a pair�*� P � where * is a �nite set and P � �� � ��� �� is a function as�
signing a number from the interval ��� �� to every subset of *� suchthat
�i� P �� � ��
�ii� P �* � �� and
�iii� P �A �B � P �A % P �B for any two disjoint sets A�B � *�
The set * can be thought of as the set of all possible outcomesof some random experiment� Its elements are called the elemen�tary events� For instance� if the experiment is rolling one fair die�the elementary events would be �� was rolled�� �� was rolled��� � � ��� was rolled�� For brevity� we can denote these elementary eventsby ��� ��� � � � � �� Subsets of * are called events� An example of an
�� Probability and probabilistic proofs
event is �an even number was rolled�� in other words f��� ��� �g�Beware� An elementary event is not an event� since events are setsof elementary events�
Probability theory has its names for various set�theoretic notionsand operations with events� For instance� �� � A� can be read as�the event A occurred�� �� � A B� can be interpreted as �boththe events A and B occurred�� �AB � �� can be expressed as �theevents A and B are incompatible�� and so on�
If A � * is an event� the number P �A is called the probability of
the event A� Axioms �i��iii express properties which we naturallyexpect from probability� From condition �iii� it is easy to see thatit su�ces to specify the values of the function P on all one�elementevents �sets� since the probability of any event equals the sum ofprobabilities of all its elementary events �more precisely� the sum ofprobabilities of all its one�element subsets� but we allow ourselvesthe abbreviated formulation�
Concerning axiom �iii in the de�nition of a �nite probabilityspace� let us remark that for any two events A�B � *� not necessarilydisjoint ones� we have the inequality P �A � B � P �A % P �B�Exercise ��
The simplest �nite probability space� and perhaps also the mostimportant one� is that in which all the elementary events have thesame probability� i�e� the function P is given by
P �A �jAjj*j
for all events A�
Such a probability space re�ects the so�called classical de�nition ofprobability� In this de�nition� formulated by Laplace� one assumes thatall possible outcomes of some random experiment are equally likelysuch an assumption can be based on some symmetry and�or homo�geneity in the experiment� If the number of all outcomes elementaryevents of the experiment is n� and� among these� there are m outcomesfavorable for some event A� then the probability of the event A is de�nedas m�n� This is sometimes expressed by the phrase that probability isthe number of favorable outcomes divided by the number of possibleoutcomes� For de�ning what probability is� the classical de�nition isnot really satisfactory the catch is in the term �equally likely� and�moreover� it doesn�t include in�nite probability spaces� but in manyspeci�c cases it is at least a useful hint for probability calculation�
��� Finite probability spaces ���
On in�nite probability spaces� By restricting ourselves to �niteprobability spaces we have simpli�ed the situation considerably from amathematical point of view� A true probability theorist would probablysay that we have also excluded everything interesting� But for mod�eling many interesting events� it is more natural to work with in�niteprobability spaces� whose de�nition is technically more complicated� Forexample� if we choose � points at random in the interval � � ��� what isthe probability that some two of them lie at distance at most �
��� We canask thousands of questions of a similar type� We would need to de�newhat means a �random point from the interval � � ��� in the �rst place�The elementary events should naturally be all the points in � � ��� Andthe probability of all individual points should be the same� at least if wewant the points to be �uniformly distributed�� and because there arein�nitely many points� the probability of each point$elementary eventmust be � Therefore� it is not possible to specify the probability func�tion P by de�ning it for the one�element events only as in the �nitecase� The probability of an event A has to be a �measure� of A in asuitable sense� This is a more complicated notion� which is closely re�lated to integration and other questions of mathematical analysis� Otherexamples of in�nite probability spaces are used� without calling themso� in Sections � �� and � ���
Next� we list several important species of �nite probability spaces�
����� De�nition �A random sequence of n s and �s�� The
elementary events of this probability space are all n�term sequences
of �s and �s� i�e� elements of the set f�� �gn� and all elementary events
have the same probability� Since the number of elementary eventsis �n� the probability of any event A equals jAj��n� We denote this
probability space by Cn�
This probability space models a sequence of n coin tosses� forinstance �assuming the coin is symmetric and heads and tails occurwith the same probability� If the ith toss yields heads we write � inthe ith position in the sequence� and for tails we write �� An exampleof an event is A ��Heads appear exactly ���� whose probability is� n��
���n�
����� De�nition �A random permutation�� Elementary eventsof this probability space are all permutations of the set f�� �� � � � � ng�and the probability of an event A equals jAj�n�� The set of all per�mutations of the set f�� �� � � � � ng is traditionally denoted by Sn� andwe denote the probability space by Sn�
��� Probability and probabilistic proofs
This space is a model for arranging some n distinct elements ina random order� e�g� for a well�shu.ed card deck�
Problem� What is the probability that in a random ordering of abridge card deck� the ace of spades precedes the king of hearts�
Reformulated in our probability model� what is the probability ofthe event A � f� � S��� ��� � ���g� We could� of course� honestlycount the permutations with ��� � ���� but we can also determinethe probability in question by a simple consideration� by symmetry� itis impossible that one of the events ���� � ���� and ���� � ����would be more likely than the other� and so the required probabilityis �
� � More precisely� such a reasoning should perhaps be formulatedas follows� We can construct a bijection between the set A and theset A� � f� � S��� ��� � ���g� To a permutation � � A� we assignthe permutation �� with ���� � ���� ���� � ���� and ���i � ��ifor i � �� Hence jAj � jA�j� and since A and A� are disjoint andtogether cover the whole probability space� we have P �A � �
� �
To revive the reader�s attention� we now include a problem with asurprising solution�
Problem� We play the following game� Our rival has � blank cards�and on each of them he writes some quite arbitrary number at will�Then he shu es the cards or� a neutral third party should better doit� and the shu ed card deck is laid on a table face down so that thenumbers are not visible� We start removing cards from the top one byone and look at their numbers� After turning any of the cards� we canend the game� We win if the last card we turned has the largest numberamong all the cards those already turned but also those still lying onthe table� If we win we take � doublezons� and if we lose we pay � doublezons� Can we expect to gain on this game�
At �rst sight it may seem that this game is not advantageous forus at all� Let us keep the following strategy� though� turn the �rst � cards no matter what� and remember the largest number we saw there�let it be M � Then turn the remaining cards� and �nish as soon as weturn a card with a number greater than or equal to M � If we encounterno such card we �nish with the last card�We claim that the probability of winning is greater than �
� for thisstrategy� Therefore� we can expect to win at least � game out of � onthe average� and so our expected gain in a long series of games will bepositive� at least about �
� � � � �� � � � ��� doublezons per game�no
fortune but enough for a beer� For simplicity� let us suppose that all thenumbers on the cards are distinct an interested reader can consider the
��� Finite probability spaces ���
modi�cation for the case of arbitrary numbers� The strategy describedsurely leads to winning if
� the largest number is among the last � cards� and� the second largest number is among the �rst � cards�
Obviously� for our strategy� the game depends solely on the orderingof the numbers and not on their actual values� and so we can imaginethat the cards contain numbers �� �� � � � � � � and their random orderingis thus an elementary event from the probability space S���� We areinterested in the event A � f� � S���� �� � � and ��� � � g�Here it is useful to think of a permutation as a linear ordering� Theposition of the number � can be chosen in � ways� the position of ��can be chosen in � ways independently of the placement of � � andthe remaining numbers can be arranged in ��� ways� Hence
P A �� � � � ���� �
�� � � �� � � +� ����� �
�
��
Let us �nish this example with a few remarks� The event A is not theonly situation in which our strategy wins� and hence the probability ofA is only a lower bound for the probability of winning� The number� used as a threshold in our strategy optimizes the probability of theevent A meaning the event that � comes after the threshold and ��before it� But if we also take other possibilities of winning into account�a somewhat better winning chance is obtained for a di�erent threshold�We will not continue a detailed analysis of the game here� we leave itas a challenge for the reader�
Next� we are going to consider the notion of a �random graph��As we will see later� there are several ways a random graph can bereasonably de�ned� Here we consider the simplest way� A simple�undirected graph on the vertex set V � f�� �� � � � � ng is speci�ed bydeciding� for each pair fi� jg � �V
�
�� whether this pair is an edge or
not� Hence there are ��n� graphs �many of them are isomorphic� of
course� but this doesn�t concern us here� If we select a random graphG on the vertex set V � in such a way that all possible graphs havethe same probability� we can view this as
�n�
�symmetric coin tosses�
That is� for each pair of vertices we toss a coin to decide whether itbecomes an edge or not� This is re ected in the following de�nition�
����� De�nition �A random graph�� This probability space� de�
noted by Gn� has all the possible graphs on vertex set f�� �� � � � � ng aselementary events� and all of them have the same probability� equal
to ���n��
��� Probability and probabilistic proofs
As examples of events in the probability space Gn we can study allsorts of natural graph properties� such as S ��the graph G is connec�ted�� B ��the graph G is bipartite�� and so on� Computing the prob�ability of such events exactly is often very di�cult� but we are usuallyinterested in a very rough estimate� For the two mentioned examples ofevents� it turns that for n � �� P S rapidly tends to � while P Bapproaches very quickly� This is sometimes expressed by saying that�a random graph is almost surely connected� and almost surely it isnot bipartite�� We prove the �rst of these two claims� by an approachtypical also for many other assertions of this type�
����� Proposition� A random graph almost surely isn�t bipartite� i�e�limn�� P B � �
Proof� As we know� the vertex set V of a bipartite graph can bepartitioned into two parts� U and W � in such a way that all edges gobetween U and W only� For a given subset U � V � let BU denote theevent that all edges of the random graph G go between vertices of Uand vertices of W � V n U only� If k � jU j� we have kn � k pairsfu�wg with u � U and w � V nU � and so the event set BU consists of
�k�n�k� graphs� Therefore P BU � �k�n�k��n�� It is not hard to check
that the function k �� kn�k attains its maximum for k � n� � and the
value of this maximum is n���� hence kn� k � n��� for all k� So wehave� for any U �
P BU � �n����n� � ��n�n������
Each bipartite graph belongs to some BU for a suitable choice of theset U� For di�erent choices of U � the events BU need not be disjoint�but in any case� the probability of a union of events is always at mostthe sum of their probabilities� and so
P B �XU�V
P BU � �n � ��n�n����� � ��n�n���� � �
�
In this problem� we were interested in a certain qualitative propertyof a �big� random graph� This somewhat resembles the situation in var�ious areas of physics such as thermodynamics or solid�state physicswhere macroscopic properties of a large collection of microscopic par�ticles are studied� It is assumed that the individual particles behaverandomly in a suitable sense� and the macroscopic properties are a re�sult of their random interactions� Also mathematical methods in thestudy of ferromagnetism and other properties of the solid�state matterare similar to methods for random graphs� Analogous approaches arealso applied in social sciences� for instance in modeling epidemics etc�
��� Finite probability spaces ���
In De�nition ������ we suppose that all graphs have the same prob�ability� or in other words� that the edge probability is �
� � In interestingproblems and applications� the edge probability is usually chosen as aparameter p generally distinct from �
� � This means that a random graphis constructed by
�n�
�coin tosses� one toss for each pair of vertices heads
means an edge and tails no edge� but the coin has the probability ofheads equal to p and the probability of tails equal to ��p� The proper�ties of the random graph are often investigated in dependence on this p�For instance� if p grows from to �� for which value does the randomgraph typically start to be connected� This is again conceptually not toofar from physics questions like� at what temperature does this crystalstart to melt�
Independent events� We have to cover one more key notion� Twoevents A�B in a probability space �*� P are called independent ifwe have
P �A B � P �AP �B�
Independence means that if * is divided into two parts� A and itscomplement� the event B �cuts� both these parts in the same ratio�In other words� if an elementary event � were chosen at randomnot in the whole * but among the elementary events from A� theprobability of � � B would be exactly equal to P �B �assumingP �A � ��
Independence does not mean that A�B � as some might perhapsthink�
Most often� we encounter independent events in the following sit�uation� The elements of *� i�e� the elementary events� can be viewedas ordered pairs� so * models the possible results of a �compound�experiment consisting of two experiments� Let us assume that thecourse and result of the �rst of these two experiments cannot possi�bly in uence the result of the second experiment and vice versa �theexperiments are separated by a thick enough wall or something� IfA � * is an event depending on the outcome of the �rst experimentonly �i�e if we know this outcome we can already decide whether Aoccurred or not� and similarly if B only depends on the outcome ofthe second experiment� then the events A and B are independent�
The space Cn �a random n�term sequence of �s and �s is a typi�cal source of such situations� Here we have a compound experimentconsisting of n subsequent coin tosses� and we assume that thesedo not in uence one another in any way� for instance� the coin isnot deformed or stolen during the �rst experiment� So� for example�
��� Probability and probabilistic proofs
if an event A only depends on the �rst � tosses ��heads appearedat least � in the �rst � tosses� and an event B only depends onthe �th and subsequent tosses ��heads appeared an odd number oftimes in tosses number � through ���� such events are independent�Similarly� in the probability space Gn �a random graph� the edgesare independent� and so for example the events �the graph G hasat least one triangle on the vertices �� �� � � � � ��� and �the graph Gcontains an odd�length cycle with vertices among ��� ��� � � � � ��� areindependent�
A subtler situation can be demonstrated in the probability spaceSn �a random permutation� The events A � f��� � �g and B �f��� � �g are clearly not independent because P �A � � andP �B � �� but A B � � and thus P �A B � �� If we de�neanother event C � f��� � �g� it is equally easy to see that B andC aren�t independent either� But maybe it is not so obvious anymorethat even A and C are not independent� we have P �A � P �C � �
nbut P �A C � �
n�n�� � P �AP �C� Intuitively� if we know that
A occurred� i�e� that ��� � �� we have also excluded one of then possibilities for the value of ���� and hence ��� has a slightlybigger chance of being equal to �� On the other hand� the events Aand D � f��� � ���g are independent� as one can check by com�puting the relevant probabilities� One has to be careful about suchsubtleties� �Perhaps the most frequent source of error in probabilisticproofs is that some events are assumed to be independent althoughin reality they are not�
The notion of independence can also be extended to several eventsA�� A�� � � � � An�
����� De�nition� Events A�� A�� � � � � An � * are called indepen�dent if we have� for each set of indices I � f�� �� � � � � ng�
P
� �i�I
Ai
��
Yi�I
P �Ai�
In particular� this de�nition requires that each two of these eventsbe independent� but we have to warn that the independence of eachpair doesn�t in general imply the independence of all events�
In the probability spaces Cn �random �)� sequence and Gn �ran�dom graph we have typical situations with many independent events�Let us de�ne an event Ai in the probability space Cn� consisting of all
��� Finite probability spaces ���
sequences with � in the ith position� Then the events A�� A�� � � � � An
are independent �we omit a proofit is not di�cult�
In various probabilistic calculations and proofs� the probabilityspaces are usually not described explicitly� one only works with themwithout saying� Nevertheless� it is important to clarify these basicnotions�
We conclude this section with a nice probability proof �histori�cally� it is one of the �rst proofs by this method�
Let us consider a tournament of n players� say a tennis tour�nament� in which each player plays against everyone else and eachmatch has a winner� If there are big di�erences among the play�ers� strength� we may expect that the best player beats everyone�the second best beats all but the �rst one� etc�� so that the tour�nament determines the order of players convincingly� A tournamentwith a more leveled strength of players can give a more complicatedoutcome� Of course� it can happen that every player is beaten bysomeone� And� mathematicians wouldn�t be mathematicians if theydidn�t ask the following generalization�
Problem� Is it possible that in some tournaments� every two play�ers are both beaten by some other player� And� more generally� forwhich numbers k can there be a tournament in which for every kplayers there exists another player who has beaten them all�
For k � �� one can construct such a tournament �by hand��But for larger values of k� the construction of such tournamentsseemed di�cult� and a solution has been sought in vain for quitesome time� But the method using probability shows the existence ofsuch tournaments �with many players quite easily� For simplicity� weshow the solution for k � � only� so we want a tournament outcomein which every � players x� y� z are all beaten by some other player� w�
Let us consider a random tournament� where we imagine that theresult of each match is determined by lot� say by tossing a fair coin�Let us look at some �xed triple fx� y� zg of players� The probabilitythat some other player� w� wins against all of them is ��� � �
� �Hence the probability that w loses against at least one of x� y� z is�� � What is the probability that each of the n � � players who canappear in the role of w loses against at least one among x� y� z�For distinct players w� the results of their matches with x� y� z are
��� Probability and probabilistic proofs
mutually independent� and so the desired probability is ��� n��� The
triple fx� y� zg can be selected in�n�
�ways� and hence the probability
that for at least one of the triples fx� y� zg� no player beats x� y� andz simultaneously� is at most
�n�
����
n��� Using a pocket calculatorwe can check that for n � ��� this probability is smaller than ��Therefore� there exists at least one result of a tournament of ��players in which any � players are simultaneously beaten by someother player� This is the desired property� �
Exercises
�� Prove that for any two events A�B in a �nite probability space� wehave P A�B � P A�P B� Generalize this to the case of n events�
�� Probabilistic formulation of inclusion$exclusion
a Formulate the inclusion$exclusion principle Theorem ����� in thelanguage of probability theory� Let A�� A�� � � � � An be events in some�nite probability space� Assuming that all elementary events in thisprobability space have the same probability� express the probabilityP A� � � � � � An using the probabilities of various intersections ofthe Ai�
b Show that the formula as in a holds for events in an arbitrary�nite probability space� The �niteness is not really needed here�
�� Prove that a random graph in the sense of De�nition ����� almostsurely contains a triangle this provides another proof for Proposi�tion ������
�� �Show that a random graph is almost surely connected�
�� Find an example of � events in some probability space� such that each� of them are independent but all � are not independent�
�� Show that if A�B are independent events then also their complements�! nA and ! nB� are independent�
�� Let !� P be a �nite probability space in which all elementary eventshave the same probability� Show that if j!j is a prime number then notwo nontrivial events distinct from and ! can be independent�
�� a Show that the events A�� A�� � � � � An in the probability space Cnde�ned in the text following De�nition ����� are really independent�
b �Let !� P be a �nite probability space� Suppose that n indepen�dent events A�� A�� � � � � An � ! exist such that � P Ai � � foreach i� Show that then j!j �n�
��� Random variables and their expectation ���
�� For simplicity� assume that the probabilities of the birth of a boy andof a girl are the same which is not quite so in reality� For a certainfamily� we know that they have exactly two children� and that at leastof them is a boy� What is the probability that they have two boys�
� � a CS Write a program to generate a random graph with a givenedge probability p and to �nd its connected components� For a givennumber n of vertices� determine experimentally at which value of p therandom graph starts to be connected� and at which value of p it startsto have a �giant component� a component with at least n
� vertices�say�
b ��Can you �nd theoretical explanations for the �ndings in a� Youmay want to consult the book �� ��
��� Random variables and their expectation����� De�nition� Let �*� P be a �nite probability space� By a ran�dom variable on *� we mean any mapping f � *� R�
A random variable f thus assigns some real number f�� to eachelementary event � � *� Let us give several examples of randomvariables�
����� Example �Number of �s�� If Cn is the probability space ofall n�term sequences of �s and �s� we can de�ne a random variablef� as follows� for a sequence s� f��s is the number of �s in s�
����� Example �Number of surviving rabbits�� Each of n hunt�ers selects a rabbit at random from a group of n rabbits� aims a gunat it� and then all the hunters shoot at once� �We feel sorry forthe rabbits but this is what really happens sometimes� A randomvariable f� is the number of rabbits that survive �assuming that nohunter misses� Formally� the probability space here is the set of allmappings � f�� �� � � � � ng � f�� �� � � � � ng� each of them having theprobability n�n� and f�� � jf�� �� � � � � ng n �f�� �� � � � � ngj�
�� Probability and probabilistic proofs
����� Example �Number of left maxima�� On the probabilityspace Sn of all permutations of the set f�� �� � � � � ng� we de�ne arandom variable f�� f��� is the number of left maxima of a permu�tation �� i�e� the number of the i such that ��i � ��j for all j � i�Imagine a long�jump contest� and assume for simplicity that eachcompetitor has a very stable performance� i�e� always jumps the samedistance� and these distances are di�erent for di�erent competitors�these� admittedly unrealistic� assumptions can be relaxed signi��cantly� In the �rst series of jumps� n competitors jump in a randomorder� Then f� means the number of times the current longest jumpchanges during the series�
����� Example �Sorting algorithm complexity�� This randomvariable is somewhat more complicated� Let A be some sorting algo�rithm� meaning that the input of A is an n�tuple �x�� x�� � � � � xn ofnumbers� and the output is the same numbers in a sorted order� Sup�pose that the number of steps made by algorithm A only depends onthe ordering of the input numbers �so that we can imagine that theinput is some permutation � of the set f�� �� � � � � ng� This conditionis satis�ed by many algorithms that only use pairwise comparisonsof the input numbers for sorting� some of them are frequently usedin practice� We de�ne a random variable f� on the probability spaceSn� we let f��� be the number of steps made by algorithm A for theinput sequence ����� ���� � � � � ��n�
����� De�nition� Let �*� P be a �nite probability space� and let
f be a random variable on it� The expectation of f is a real numberdenoted by E �f � and de�ned by the formula
E �f � �X��
P �f�gf���
In particular� if all the elementary events � � * have the sameprobability �as is the case in almost all of our examples� then theexpectation of f is simply the arithmetic average of the values of fover all elements of *�
E �f � ��
j*jX��
f���
The expectation can be thought of as follows� if we repeat a randomchoice of an elementary event � from * many times� then the averageof f over these random choices will approach E �f ��
��� Random variables and their expectation ���
Example ����� �Number of �s� continued� For an illustration�we compute the expectation of the random variable f�� the numberof �s in an n�term random sequence of �s and �s� according to thede�nition� The random variable f� attains a value � for a single se�quence �all �s� value � for n sequences� � � � � value k for
�nk
�sequences
from Cn� Hence
E �f�� ��
�n
Xs�f���gn
f��s
��
�n
nXk��
�n
k
�k�
As we will calculate in Example ������� the �nal sum equals n�n���and so E �f�� � n
� � Since we expect that for n coin tosses� headsshould occur about n
� times� the result agrees with intuition�The value of E �f�� can be determined in a simpler way� by the
following trick� For each sequence s � Cn we consider the sequence +sarising from s by exchanging all �s for �s and all �s for �s� We havef��s % f��+s � n� and so
E �f�� ��
�n
Xs�f���gn
f��s ��
�n � �X
s�f���gn�f��s % f��+s
� ��n���nn �n
��
We now describe a method that often allows us to compute theexpectation in a surprisingly simple manner �we saw that the calcu�lation according to the de�nition can be quite laborious even in verysimple cases� We need a de�nition and a simple theorem�
���� De�nition� Let A � * be an event in a probability space
�*� P � By the indicator of the event A we understand the random
variable IA� *� f�� �g de�ned in the following way�
IA�� �
�� for � � A� for � � A�
�So the indicator is just another name for the characteristic functionof A��
��� Probability and probabilistic proofs
����� Observation� For any event A� we have E �IA� � P �A�
Proof� By the de�nition of expectation we get
E �IA� �X��
IA��P �f�g �X�A
P �f�g � P �A�
�
The following result almost doesn�t deserve to be called a theoremsince its proof from the de�nition is immediate �and we leave it tothe reader� But we will �nd this statement extremely useful in thesequel�
����� Theorem �Linearity of expectation�� Let f� g be arbitraryrandom variables on a �nite probability space �*� P � and let be a
real number� Then we have E �f � � E �f � and E �f % g� � E �f � %E �g�� �
Let us emphasize that f and g can be totally arbitrary� and neednot be independent in any sense or anything like that� �On the otherhand� this nice behavior of expectation only applies to adding ran�dom variables and multiplying them by a constant� For instance� itis not true in general that E �fg� � E �f �E �g�� Let us continue witha few examples of how ����������� can be utilized�
Example ����� �Number of �s� continued again� We calculateE �f��� the average number of �s� in perhaps the most elegant way�Let the event Ai be �the ith coin toss gives heads�� so Ai is theset of all n�term sequences with a � on the ith position� Obviously�P �Ai �
�� for all i� We note that for each sequence s � f�� �gn we
have f��s � IA��s % IA��s % � � � % IAn�s �this is just a rathercomplicated way to write down a trivial statement� By linearity ofexpectation and then using Observation ����� we obtain
E �f�� � E �IA� � %E �IA� � % � � �%E �IAn �
� P �A� % P �A� % � � �% P �An �n
��
�
Example ����� �Number of surviving rabbits� continued� Wewill compute E �f��� the expected number of surviving rabbits� This
��� Random variables and their expectation ���
�i� �i� ��� � � � �� are still in
� � � � � �� � i i� � n� � n
�i� � �n�n� �
Fig� ��� A procedure for selecting a random permutation�
time� let Ai be the event �the ith rabbit survives�� formally� Ai is theset of all mappings that map no element to i� The probability thatthe jth hunter shoots the ith rabbit is �
n � and since the hunters selectrabbits independently� we have P �Ai � �� � ��nn� The remainingcalculation is as in the preceding example�
E �f�� �nXi��
E �IAi� �
nXi��
P �Ai �
��� �
n
�nn � n
e
�since �� � ��nn converges to e�� for n � �� see Exercise ������About ��, of the rabbits survive on the average� �
Example ����� �Number of left maxima� continued� Now wewill calculate the expected number of left maxima of a random per�mutation� E �f��� Let us de�ne Ai as the event �i is a left max�imum of ��� meaning that Ai � f� � Sn� ��i � ��j for j ��� �� � � � � i��g� We claim that P �Ai �
�i � Perhaps the most intuitive
way of deriving this is to imagine that the random permutation � isproduced by the following method� We start with a bag containingthe numbers �� �� � � � � n� We draw a number from the bag at randomand declare it to be ��n� Then we draw another random numberfrom the bag which becomes ��n� � etc�� as in Fig� ���� The valueof ��i is selected at the moment the bag contains exactly i numbers�The probability that we choose the largest one of these i numbersfor ��i �which is exactly the event Ai thus equals �
i � The rest isagain the same as in previous examples�
E �f�� �nXi��
E �IAi� �
nXi��
P �Ai � � %�
�%
�
�% � � �% �
n�
The value of the sum of reciprocals on the right�hand side is roughlylnn� see Section ���� �
��� Probability and probabilistic proofs
Exercises
�� Show with examples that if f and g are arbitrary random variablesthen none of the following equalities must necessarily hold� E �fg� �
E �f �E �g�� E�f��� E �f �
�� E ���f � � ��E �f ��
�� Prove that E�f�� E �f �
�holds for any random variable f �
�� Let f� be the number of �xed points of a permutation � see Sec�tion ���� Compute E �f � for a random permutation � in the space Sn�
�� Let � be a random permutation of the set f�� �� � � � � ng�a �Determine the expected length of the cycle of � containing thenumber � see Section ��� for the de�nition of a cycle�
b �Determine the expected number of cycles of ��
�� A bus route connects downtown Old Holstein with the local universitycampus� Mr� X�� a student at the university� takes the bus from down�town every weekday after he wakes up� which happens at a randomtime of the day �� hours� According to his records� he has to waitfor the bus for � minutes on the average� At the same time� the buscompany claims that the average interval between two buses duringthe day over the period of �� hours is �� minutes� Can you constructa schedule such that both Mr� X� and the bus company are right�
�� �We toss a fair coin n times� What is the expected number of �runs��Runs are consecutive tosses with the same result� For instance� thetoss sequence HHHTTHTH has � runs�
�� Markov inequality Let X be a random variable on some probabilityspace attaining nonnegative values only� Let � � E �X � be its expecta�tion� and let t � be a real number� Prove that the probability thatX attains a value t� is at most �
t � in sympols�
P f� � !� X� t�g � �t�
This is a simple but quite important inequality� It is often used if wewant to show that the probability of some quantity getting too big issmall�
�� a What is the expected number of surviving rabbits in Example �����if there are m rabbits and n hunters�
b �Using Exercise � and suitable estimates� show that if we haven � mlnm� � then with probability at least ���� no rabbit survives�In other words� most of the mappings from an n�element set into anm�element set are onto�
c �Solve part b di�erently� use the derivation of the formula for thenumber of mappings onto via inclusion$exclusion Exercise ����� andthe Bonferroni inequality ��� with q � ��
��� Several applications ���
��� Several applicationsIn this section� we have collected examples of using the probabilisticmethod and the linearity of expectation in particular� They are notroutine examples but rather small mathematical gems�
Existence of large bipartite subgraphs� Given a graph G ��V�E� we would like to partition the vertex set into two parts insuch a way that as many edges as possible go between these parts�Moreover� we often need that the parts have an approximately equalsize� The following theorem shows that we can always make at leasthalf of the edges go between the parts� and� moreover� that the partscan be chosen with an equal size �if the number of vertices is even�
����� Theorem� Let G be a graph with an even number� �n� ofvertices and with m � � edges� Then the set V � V �G can be
divided into two disjoint n�element subsets A and B in such a way
that more than m� edges go between A and B�
Proof� Choose A as a random n�element subset of V � all the��nn
�n�element subsets having the same probability� and let us put B �V n A� Let X denote the number of edges of G going �across�� i�e�edges fa� bg with a � A and b � B� We calculate the expectationE �X� of the random variable X� For each edge e � fu� vg � E�G�we de�ne the event Ce that occurs whenever the edge e goes betweenA and B� formally� Ce � fA � �V
n
�� jA ej � �g� Then we have
X �P
e�E�G ICe � and hence E �X� �P
e�E�G P �Ce� So we need todetermine the probability P �Ce�
Altogether� there are��nn
�possible choices of A� If we require that
u � A and v � A� the remaining n� � elements of A can be selectedin
��n��n��
�ways� Similar reasoning works for the symmetric situation
u � A� v � A� Thus
P �Ce ����n��n��
���nn
� �n
�n� ��
�
��
From this we get E �X� �P
e�E�G P �Ce �m� � The expectation of
X is the arithmetic average of the values of X over all choices of theset A� An average cannot be greater than the maximum of all thesevalues� and therefore a choice of A exists with more than half of theedges going across� �
Independent sets� This is related to the subject of Section ����extremal graph theory� Here we ask� how many edges can a graph
��� Probability and probabilistic proofs
on n vertices have if it doesn�t contain the complete graph on k ver�tices as a subgraph� In particular� for k � �� how many edges cana graph on n vertices with no triangles have� This question is an�swered by Tur�an�s theorem� one of the celebrated results of extremalgraph theory� This theorem can be formulated in various ways� Thestrongest version describes exactly how a graph with the maximumpossible number of edges looks� Here we demonstrate a very cuteprobabilistic proof� We only give the bound on the maximum num�ber of edges� With some more work� one can also derive the structureof the graph with the maximum possible number of edges� but weomit that part�
Tur�an�s theorem is most often applied in a �reverse� form� if agraph on n vertices has more than a certain number of edges then it
has to contain a Kk� If we consider the complement of the graph G�i�e� edges in the new graph are exactly at the positions where G hasno edges� Tur�an�s theorem says if a graph on n vertices has fewer
than a certain number of edges then it contains an independent set
of size at least k �an independent set is a set of vertices such thatno two of them are connected by an edge� This is perhaps the mostuseful version for applications� and it is also the one we state andprove here�
����� Theorem �Tur�an�s theorem�� For any graph G on n ver�
tices� we have
�G � n�
�jE�Gj% n�
where �G denotes the size of the largest independent set of verticesin the graph G�
The probabilistic method is used in the proof of the next lemma�
Lemma� For any graph G� we have
�G �X
v�V �G
�
degG�v % �
�where degG�v denotes the degree of a vertex v in the graph G��
Proof� Suppose that the vertices of G are numbered �� �� � � � � n�and let us pick a random permutation � of the vertices� We de�nea set M � M�� � V �G consisting of all vertices v such that allneighbors u of v satisfy ��u � ��v� that is� the vertex v precedes
��� Several applications ���
all neighbors in the ordering given by the permutation �� Note thatthe set M�� is an independent set in G� and so jM��j � �G forany permutation �� Hence also E �jM j� � �G� We now calculatethe expected size of M in a di�erent way�
For a vertex v� let Av be the event �v � M���� If Nv denotesthe set of all neighbors of the vertex v� then all the orderings of theset Nv � fvg by the permutation � have the same probability� andso the probability of v being the smallest element of this set equals���jNv j%� � ���degG�v%�� Therefore P �Av � ���degG�v%��and we can calculate as we already did several times before�
�G � E �jM j� �X
v�V �G
E �IAv �
�X
v�V �G
P �Av �X
v�V �G
�
degG�v % ��
�
Proof of Theorem ������ This is now a mere calculation withinequalities� The number of edges e � jE�Gj is half of the sum of thevertex degrees� So we have the following situation� for nonnegativereal numbers d�� d�� � � � � dn� we know that
Pni�� di � �e� and we ask
what the smallest possible value is of the sum
nXi��
�
di % ��
It can be shown that this sum is minimized for d� � d� � � � � � dn ��e�n �we leave this as an exercise� and in such a case� its value isn����e % n as in the theorem� �
Number of intersections of level � k� This is a geometric prob�lem arising in the analysis of certain geometric algorithms� Let usconsider a set L consisting of n lines in the plane� such that no threelines of L meet at a common point and no two of them are parallel�Let o be a point lying on none of the lines of L� We will considerthe pairwise intersections of the lines of L� Each pair of lines has oneintersection� so there are
�n�
�intersections altogether� Let us say that
an intersection v has level k if the segment ov intersects� in additionto the two lines de�ning the intersection v� exactly k more lines ofL �Fig� ��� depicts all intersections of level �� What is the maxi�mum possible number of intersections of level at most k� for a given
��� Probability and probabilistic proofs
������������������������
llllllllllllll
�
�������������tt
t t tto
Fig� ��� Intersections of level � for a set of lines�
n and k� The following theorem gives an upper bound which is thebest possible up to the value of the constant of proportionality�
����� Theorem� For any set of n lines� there exist at most ��k%�nintersections of level at most k�
Proof� First we look at the particular case k � �� We �nd that theintersections of level � are exactly the vertices of the convex polygoncontaining the point o� Since each line contributes at most one sideof this polygon� the number of its sides is at most n� and hence alsothe number of intersections of level � is at most n� We will use thisin the proof for an arbitrary k� which we do next�
Let p denote a certain suitable number in the interval ��� �� whosevalue will be determined at the end of the proof� Let us imagine thefollowing random experiment� We choose a subset R � L at random�by choosing each line � � L with probability p� these choices beingindependent for distinct lines ��
Here we should perhaps say a little more about the underlying prob�ability space� It is a generalization of the space Cn from Example ������That example models tosses of a symmetric coin� where both heads andtails have the same probability� namely �
� � In the case considered here�we would use an asymmetric coin of some kind� where heads have prob�ability p and tails probability � � p� For each line � � L� we toss thisasymmetric coin once� and we include � into our sample R if the tossyields heads� Formally� the probability space is the set of all subsetsof L� and the probability of an r�element set R � L is pr� � pn�r�where r � jRj in order to get exactly the set R by the coin tosses�
��� Several applications ���
certain r tosses must give heads and the remaining n� r tosses tails�This is also an example of a probability space where the elementaryevents need not have all the same probability�
Let us return to our geometric situation� We have thus chosena random set R � L of lines� Let us imagine that only the lines ofR are drawn in the plane� We de�ne a random variable f � f�Ras the number of intersections that have level � with respect to thelines of R� that is� intersections of lines of R such that no line ofR obscures their view of the point o� We are going to estimate theexpectation E �f � in two ways� On one hand� by the remark at thebeginning of the proof� we have f�R � jRj for any speci�c set R�and hence E �f � � E �jRj�� It is not di�cult to calculate �we leavethis to Exercise � that E �jRj� � pn�
Now we will count E �f � in a di�erent way� For each intersectionv of the lines of L� we de�ne an event Av that occurs if and only ifv is one of the intersections of level � with respect to the lines of R�i�e� it contributes � to the value of f�R� The event A occurs if andonly if the following two conditions are satis�ed�
� Both the lines determining the intersection v lie in R�
� None of the lines intersecting the segment ov at an interior point�and thus obscuring the view from the point v to the point ofalls into R�
From this� we deduce that P �Av � p����p��v � where ��v denotesthe level of the intersection v�
Let M denote the set of all intersections of the lines of L� and letMk �M be the set of intersections at level at most k� We have
E �f � �Xv�M
E �IAv � �Xv�M
P �Av �Xv�Mk
P �Av
�Xv�Mk
p���� p��v �Xv�Mk
p���� pk � jMkjp���� pk�
Altogether we have derived np � E �f � � jMkjp��� � pk� in otherwords
jMkj � n
p��� pk�
Let us now choose the number p in such a way that the value ofthe right�hand side is as small as possible� A suitable choice is� forinstance� p � ���k % �� By Exercise ������ we have �� � �
k�k �
�� Probability and probabilistic proofs
e�� � �� for any k � �� This leads to jMkj � ��k % �n as the
theorem claims� �
Let us remark that the problem of estimating the maximum pos�sible number of intersections of level exactly k is much more di�cultand still unsolved� The branch of mathematics studying problems of asimilar nature� i�e� combinatorial questions about geometric con�gura�tions� is called combinatorial geometry� A highly recommendable bookfor studying this subject is Pach and Agarwal ����� A more specializedbook considering problems closely related to estimating the number ofintersections of level k is Sharir and Agarwal �����
Average number of comparisons in QUICKSORT� Algo�rithm QUICKSORT� having received a sequence �x�� x�� � � � � xn ofnumbers as input� proceeds as follows� The numbers x�� x�� � � � � xnare compared to x� and divided into two groups� those smaller thanx� and those at least as large as x�� In both groups� the order ofnumbers remains the same as in the input sequence� Each group isthen sorted by a recursive invocation of the same method� The re�cursion terminates with trivially small groups �at most one�elementones� say� For example� the input sequence ��� �� �� �� �� �� � wouldbe sorted as follows�
�� �� �� �� �� �� �
�� �� � �� �� �
�� � � �
�
This algorithm may need about n� steps in the worst case �theworst thing we can do to the algorithm is to confront it with analready sorted sequence� In practice� however� QUICKSORT is verypopular� and it is considered one of the fastest sorting algorithms�It behaves very well �on average�� This is partially expressed in thefollowing theorem�
����� Theorem� Let x� � x� � � � � � xn be a sequence of real
numbers in an increasing order� Let � be a permutation of the
set f�� �� � � � � ng� and let T �� be the number of comparisons �of
pairs of elements� made by QUICKSORT for the input sequence
��� Several applications ���
�x��� � x��� � � � � � x��n � Then the expectation of T �� for a random
permutation � is at most �n lnn�
Let us remark that any algorithm that sorts every n�tuple of distinctreal numbers and uses only pairwise comparisons of these numbers hasto make at least log� n� comparisons in the worst case� This is becausethe algorithm must select one of the n� possible permutations accordingto the outcomes of the comparisons� and k comparisons only have �k
di�erent outcomes� As we know from Section ���� we have n� �ne
�n�
and so log� n� � log� e lnn� log� en� � lnn � �����n� � lnn�Therefore� the average behavior of QUICKSORT guaranteed by Theo�rem ����� is quite good�
Reasons for the O�n logn average behavior of the QUICKSORTalgorithm are not di�cult to see� When the input elements are ran�domly ordered� we expect that the �rst element usually divides theremaining elements into two groups of roughly comparable sizeit isunlikely that one group is much smaller than the other� If this hap�pens in most cases� the recursion in the algorithm will have roughlylog n levels� and at each level of recursion we need O�n comparisonsin total�
This may sound quite convincing� but certainly it is not a proof�Next� we give a rigorous proof� based on a rather di�erent idea�
Proof of Theorem ������ Let Ti � Ti�� be the number of el�ements compared to the element x��i at the moment x��i is thedividing element� For instance� we always have T� � n � �� sincex��� is the �rst element in the input sequence� and all the otherelements are compared to it� If ��� � ���� T� is ��� � �� andfor ��� � ��� we have T� � n � ��� � �� In general� Ti can beinterpreted according to the following diagram�
d d t d t t d d d t d d dthx��i
����
The small circles in this diagram depict the elements x�� x�� � � � � xnin the sorted order� The full circles are the elements with indices���� ���� � � � � ��i � �� i�e� the �rst i � � elements in the input se�quence� The element x��i is marked by a double circle� and theremaining elements have empty circles� It is not di�cult to see thatTi is exactly the number of empty circles �seen� by the element x��i �if the full circles are considered opaque�
��� Probability and probabilistic proofs
We will investigate the expectation of Ti� They key idea is to thinkof the algorithm running backwards in time� as if we were watchinga movie going backwards� Imagine that we consider the indices i inthe backward order n� n��� � � � � �� and we look at the correspondingpicture with full and empty circles� Initially� all the circles are full�The random permutation � is not yet de�ned� and we create it byrandom choices as we go along� First we choose one full circle atrandom and make it empty� The index of this circle becomes ��n�Then we randomly select another full circle and make it empty� whichdetermines ��n � �� and so on� this is the same way of generatinga random permutation as in Fig� ���� At the moment when i fullcircles remain� we choose one of them at random� which correspondsto x��i � The quantity Ti is the number of empty circles seen by x��i at this moment�
To estimate the expected value of Ti� we use double�counting�Each of the n � i empty circles sees at most two full circles� Hencethe total number of pairs �full circle�empty circle whose memberssee each other is at most ��n � i� On the average� one of the i full
circles sees at most ��n�i i empty circles� and hence E �Ti� � ��n�i
i �Since T �� �
Pni�� Ti��� we get
E �T � �nXi��
E �Ti� �nXi��
��n� i
i� �n
nXi��
�
i� �n � �n lnn�
�
Remark� It can be shown that the probability of the runningtime of QUICKSORT deviating from the expectation by a signi�cantamount is quite small �exponentially small� i�e� bad permutationsare quite rare� We will not consider this here�
Exercises
�� From Theorem ������ prove that any graph on n vertices with no tri�angles has at most n��� edges�
�� �Show that if d�� � � � � dn are nonnegative real numbers adding up to ��then the expression
Pni�� ��di � � is minimal for d� � d� � � � � �
dn � ��n�
�� Consider the following algorithm for �nding an independent set in agraph G� Keep deleting a vertex of the maximum degree from the cur�rent graph� together with edges containing it� until the current graph
��� Several applications ���
has no edges� Show that this algorithm always �nds an independentset of size at least F G �
PvV �G� ��� � degGv� Hint� Check
that if H arises from G by deleting a maximum degree vertex thenF H F G�
�� �Prove the following version of Tur'an�s theorem� Let r � be an in�teger� and let n be divisible by r � �� Then any graph on n vertices
containing no Kr as a subgraph has at mostn�
�
��� �
r��
�edges� Pro�
ceed by induction on the number nr�� �
�� Let G be a graph� Consider the following algorithm� Divide V G intotwo parts A and B arbitrarily� and repeat the following step while ap�plicable� if there is a vertex with more neighbors in the part containingit than in the other part� select some such vertex and move it to theother part than the one currently containing it� Show that this algo�rithm always �nishes and give as a good bound on the running timeas possible� and that at least half of the edges of G go between theresulting parts A�B�
�� a Modify the above algorithm QUICKSORT as follows� Let the cur�rent input sequence be x�� x�� � � � � xn� Choose a random number iamong �� �� � � � � n all values have probability �
n � and use xi as thedividing element� Show that for any �xed n�tuple of input numbersx�� x�� � � � � xn� assuming that no two of them are equal� the expectednumber of comparisons is the same and is bounded by �n lnn as inTheorem ������
b �Consider another modi�cation of the algorithm� given an inputsequence x�� x�� � � � � xn� choose two independent random numbersi�� i� from f�� �� � � � � ng� and use maxxi� � xi� as the dividing element�Suppose that x�� x�� � � � � xn are all distinct� Show that the expectednumber of comparisons for a given input sequence is the same as in a�We do not count the comparisons needed to determine maxxi� � xi��
�� �Consider n empty circles in a row� An observer sits in one of the n��gaps between them� A random subset of r circles is colored black� Showthat the expected number of empty circles the observer sees is at most�n� r�r ��� The observer can see through empty circles but notthrough black ones� Hint� Instead of coloring r circles color r � � ofthem black �rst and then make a random black circle empty again�
�� Let the subset R � L be chosen at random as in the proof of Theo�rem ������ Prove that E �jRj� � pn�
�� �Consider n lines as in Theorem ������ assuming� moreover� that noneof them is vertical� We say that an intersection v is a peak if one ofthe lines de�ning it has a positive slope and the other one a negativeslope� Prove that at most �k � �� peaks of level at most k exist�
�
Generating functions
In this chapter� we are going to present a useful calculation technique�The basic idea� quite a surprising one� is to consider an in�nite se�quence of real numbers and associate a certain continuous functionwith it� the so�called generating function of the sequence� Problemsabout sequences can then be solved by calculations with functions�
In this introductory text� we will only get to simpler examples� whosesolution can mostly be found also without generating functions� In someproblems� various tricks can reach the goal even quicker than the methodof generating functions but it may not be easy to discover such tricks�This should not discourage the reader from learning about generatingfunctions� since these are a powerful tool also for more advanced prob�lems where other methods fail or become too complicated�In some solutions� alternative methods are mentioned� for others
they are indicated in the exercises� Sometimes the reader will perhaps�nd even simpler solutions�
���� Combinatorial applications of polynomials
How do we multiply the polynomials p�x � x % x� % x� % x� andq�x � x%x�%x�� Here is a simple rule� multiply each term of p�xby each term of q�x and add all these products together� Adding theproducts is simple� since all the products have coe�cient �� In thisway� we calculate that p�xq�x � x�%�x�%�x%�x�%�x�%x�%x��
Let us now ask a di�erent question� We pick some power of x�say x�� and we want to know its coe�cient in p�xq�x� withoutcalculating the whole product� In our case� x� appears by multiplyingthe term x in p�x by x� in q�x� and also by multiplying x� in p�xby x� in q�x� and �nally by multiplying x� in p�x by x in q�x�Each of these possibilities adds � to the resulting coe�cient� andhence the coe�cient of x� in the product p�xq�x is ��
This is as if we had � silver coins with values �� �� �� and �doublezons �these are the exponents of x in the polynomial p�x and
���� Combinatorial applications of polynomials ���
� golden coins with values �� �� and � doublezons �corresponding tothe exponents of x in q�x� and asked how may ways there are topay � doublezons by one silver and one golden coin� Mathematicallyspeaking� the coe�cient of x� is the number of ordered pairs �i� j�where i% j � �� i � f�� �� �� �g� and j � f�� �� �g�
Let us express the consideration just made for the two particularpolynomials somewhat more generally� Let I and J be �nite sets ofnatural numbers� Let us form the polynomials p�x �
Pi�I xi and
q�x �P
j�J xj �note that the coe�cients in such polynomials are�s and �s� Then� for any natural number r� the number of solutions�i� j of the equation
i% j � r
with i � I and j � J equals the coe�cient of xr in the productp�xq�x�
A further� more interesting generalization of this observation dealswith a product of � or more polynomials� Let us illustrate it on aparticular example �rst�
Problem� How many ways are there to pay the amount of �� dou�blezons if we have � one�doublezon coins� � two�doublezon coins� and� �ve�doublezon coins�
Solution� The required number equals the number of solutions ofthe equation
i� % i� % i� � ��
with
i� � f�� �� �� �� �� �� �g� i� � f�� �� �� �� �� ��g� i� � f�� �� ��� ��� ��g�Here i� is the amount paid by coins of value � doublezon� i� theamount paid by ��doublezon coins� and i� the amount paid by ��doublezon coins�
This time we claim that the number of solutions of this equationequals the coe�cient of x�� in the product�
� % x% x� % x� % � � � % x��
� % x� % x� % x % x� % x���
�� % x� % x�� % x�� % x��
��after multiplying out the parentheses and combining the terms withthe same power of x� of course� Indeed� a term with x�� is obtained
��� Generating functions
by taking some term xi� from the �rst parentheses� some term xi�
from the second� and xi� from the third� in such a way that i�% i�%i� � ��� Each such possible selection of i�� i�� and i� contributes �to the considered coe�cient of x�� in the product�
How does this help us in solving the problem� From a purely prac�tical point of view� this allows us to get the answer easily by computer�provided that we have a program for polynomial multiplication at ourdisposal� In this way� the authors have also found the result� �� Since weonly deal with relatively few coins� the solution can also be obtained bylisting all possibilities� but it could easily happen that we forget some�However� the method explained above is most signi�cant as a preludeto handling more complicated situations�
A combinatorial meaning of the binomial theorem� The bi�nomial theorem asserts that
�� % xn �
�n
�
�%
�n
�
�x%
�n
�
�x� % � � �%
�n
n
�xn� �����
On the left�hand side� we have a product of n polynomials� each ofthem being �%x� Analogously to the above considerations with coins�the coe�cient of xr after multiplying out the parentheses equals thenumber of solutions of the equation
i� % i� % � � �% in � r�
with i�� i�� � � � � in � f�� �g� But each such solution to this equationmeans selecting r variables among i�� i�� � � � � in that equal �then � r remaining ones must be �� The number of such selections isthe same as the number of r�element subsets of an n�element set�i�e�
�nr
�� This means that the coe�cient of xr in the product ��%xn
is�nr
�� We have just proved the binomial theorem combinatorially�
If we play with the polynomial ��%xn and similar ones skillfully�we can derive various identities and formulas with binomial coe��cients� We have already seen simple examples in Section ���� namelythe formulas
Pnk��
�nk
�� �n and
Pnk�����k
�nk
�� � obtained by
substituting x � � and x � �� into ������ respectively�For the next example� the reader should be familiar with the
notion of a derivative �of a polynomial�
� ���� Example� For all n � �� we have
nXk��
k
�n
k
�� n�n���
���� Combinatorial applications of polynomials ���
Proof� This equality can be proved by di�erentiating both sidesof the formula ����� as a function of the variable x� On both sides�we must obtain the same polynomial� By di�erentiating the left�handside we get n��%xn��� and di�erentiating the right�hand side yieldsPn
k�� k�nk
�xk��� By setting x � � we get the desired identity� �
An example of a di�erent type is based on the equality of coe��cients in two di�erent expressions for the same polynomial�
Another proof of Proposition ������ We want to prove
nXi��
�n
i
��
�
��n
n
��
Consider the identity
�� % xn�� % xn � �� % x�n�
The coe�cient of xn on the right�hand side is��nn
�by the binomial
theorem� On the left�hand side� we can expand both the powers�� % xn according to the binomial theorem� and then we multiplythe two resulting polynomials� The coe�cient of xn in their productcan be expressed as
�n�
��nn
�%�n�
�� nn��
�%�n�
�� nn��
�%� � �%�n
n
��n�
�� and this
must be the same number as the coe�cient of xn on the right�handside� This leads to
nXi��
�n
i
��n
n� i
��
��n
n
��
So we have proved Proposition ����� in a di�erent way� �
A number of other sums and formulas can be handled similarly�But if we try some more complicated calculations� we soon encounter�as an unpleasant restriction� the fact that we work with polynomialshaving �nitely many terms only� It turns out that the �right� tool forsuch calculations is an object analogous to a polynomial but with pos�sibly in�nitely many powers of x� the so�called power series� This is thesubject of the next section�
Exercises
�� Let ax � a��a�x�a�x��� � ��anxn and bx � b��b�x�b�x
��� � ��bmx
m be two polynomials� Write down a formula for the coe�cient ofxk in the product axbx� where � k � n�m�
��� Generating functions
�� A co�ee shop sells three kinds of cakes�Danish cheese cakes� Germanchocolate cakes� and brownies� How many ways are there to buy ��cakes in such a way that at least � cakes of each kind are included�but no more than � German chocolate cakes� Express the requirednumber as a coe�cient of a suitable power of x in a suitable productof polynomials�
�� How many ways are there to distribute � identical balls among � boysand � girls� if each boy should get at least � ball and each girl shouldget at least � balls� Express the answer as a coe�cient of a suitablepower of x in a suitable product of polynomials�
�� Prove the multinomial theorem ����� in similarly way as the binomialtheorem was proved in the text�
�� Calculate the sum in Example � ���� by a suitable manipulation of theexpression k
�nk
�and by using the binomial theorem�
�� Compute the sumPn
i����i�ni
��nn�i
��
���� Calculation with power series
Properties of power series� A power series is an in�nite series ofthe form a� % a�x% a�x
� % � � �� where a�� a�� a�� � � � are real numbersand x is a variable attaining real values�� This power series willusually be denoted by a�x�
A simple example of a power series is
� % x% x� % x� % � � � �����
�all the ai are �� If x is a real number in the interval ���� �� thenthis series converges and its sum equals �
��x �this is the well�knownformula for the sum of an in�nite geometric series� if you�re notfamiliar with it you should certainly consider doing Exercise �� Inthis sense� the series ����� determines the function �
��x � Conversely�this function contains all the information about the series ������Indeed� if we di�erentiate the function k times and then substitutex � � into the result� we obtain exactly k� times the coe�cient of xk�In other words� the series ����� is the Taylor series of the function�
��x at x � �� Hence the function ���x can be understood as an
incarnation of the in�nite sequence ��� �� �� � � � and vice versa� Such
�It is extremely useful to consider also complex values of x and to applymethods from the theory of functions of a complex variable� But we are notgoing to get this far in our introductory treatment�
���� Calculation with power series ���
a transmutation of in�nite sequences into functions and back is akey step in the technique of generating functions�
In order to explain what generating functions are� we have to usesome notions of elementary calculus convergence of in�nite series� de�rivative� Taylor series� as we have already done in the example justgiven� If you�re not familiar with enough calculus to understand thisintroduction� you still need not give up reading� because almost noth�ing from calculus is usually needed to solve problems using generatingfunctions� For example� you can accept as a matter of faith that thein�nite series � � x � x� � � � � and the function �
��x mean the samething� and use this and similar facts listed below for calculations�
The following proposition says that if the terms of a sequence�a�� a�� a�� � � � do not grow too fast� then the corresponding powerseries a�x � a� % a�x % a�x
� % � � � indeed de�nes a function of thereal variable x� at least in some small neighborhood of �� Further�from the knowledge of the values of this function we can reconstructthe sequence �a�� a�� a�� � � � uniquely�
� ���� Proposition� Let �a�� a�� a�� � � � be a sequence of real num�
bers� and let us suppose that for some real number K� we have
janj � Kn for all n � �� Then for any number x � �� �K �
�K � the
series a�x �P
i�� aixi converges �even absolutely�� and hence the
value of its sum de�nes a function of the real variable x on this in�
terval� This function will also be denoted by a�x� The values of thefunction a�x on an arbitrarily small neighborhood of � determine all
the terms of the sequence �a�� a�� a�� � � � uniquely� That is� the func�tion a�x has derivatives of all orders at �� and for all n � �� �� �� � � �we have
an �a�n ��
n�
�a�n �� stands for the nth derivative of the function a�x at the
point ���
A proof follows from basic results of mathematical analysis� and weomit it here as we do for proofs of a few other results in this section�Most natural proofs are obtained from the theory of functions of acomplex variable� which is usually covered in more advanced coursesonly� But we need very little for our purposes� and this can be proved�somewhat more laboriously� also from basic theorems on limits andderivatives of functions of a real variable� In the subsequent examples�we will not explicitly check that the power series in question convergein some neighborhood of i�e� the assumptions of Proposition � �����Usually it is easy� Moreover� in many cases� this can be avoided in
� Generating functions
the following way� once we �nd a correct solution of a problem usinggenerating functions� in a possibly very suspicious manner� we can verifythe solution by some other method� say by induction� And� �nally� weshould remark that there is also a theory of the so�called formal powerseries� which allows one to work even with power series that neverconverge except at in a meaningful way� So convergence is almostnever a real issue in applications of generating functions�
Now� �nally� we can say what a generating function is�
� ���� De�nition� Let �a�� a�� a�� � � � be a sequence of real num�bers� By the generating function of this sequence� we understand
the power series a�x � a� % a�x% a�x� % � � ��
If the sequence a�� a�� a�� � � � has only �nitely many nonzero terms�then its generating function is a polynomial� Thus� in the precedingsection� we have used generating functions of �nite sequences withoutcalling them so�
Manufacturing generating functions� In applications of gen�erating functions� we often encounter questions like �What is thegenerating function of the sequence ��� �� �
�� �
�� � � � ��� Of course� the
generating function is � % ��x% �
�x� % �
�x� % � � � by de�nition� but is
there a nice closed formula� In other words� doesn�t this power seriesde�ne some function well known to us from calculus� say� �This one
does� namely � ln���x x � see below� The answer can often be found by
an �assembling� process� like in a home workshop� We have a supplyof parts� in our case sequences like ��� �� �� � � �� for which we knowthe generating function right away� We also have a repertoire of sim�ple operations on sequences and their corresponding operations onthe generating functions� For example� knowing the generating func�tion a�x of some sequence �a�� a�� a�� � � �� the generating functionof the sequence ��� a�� a�� a�� � � � equals x a�x� With some skill� wecan usually �assemble� the sequence we want�
Let us begin with a supply of the �parts�� Various examples ofTaylor �or Maclaurin series mentioned in calculus courses belong to
�A more detailed name often used in the literature is the ordinary gener�
ating function� This suggests that other types of generating functions are alsoused in mathematics� We brie y mention the so�called exponential generating
functions� which are particularly signi�cant for combinatorial applications� Theexponential generating function of a sequence �a�� a�� a�� � � �� is the power seriesP�
i���ai�i��x
i� For example� the sequence � � � � � � �� has the exponential gener�ating function ex� In the sequel� except for a few exercises� we restrict ourselvesto ordinary generating functions�
���� Calculation with power series ��
such a supply� For instance� we have
x
�%x�
�%x�
�% � � � � � ln��� x �����
�valid for all x � ���� � and
� %x
��%x�
��%x�
��% � � � � ex
�holds for all real x� Lots of other examples can be found in cal�culus textbooks� Here is another easy calculus result� which is usedparticularly often�
� ���� Proposition �Generalized binomial theorem�� For anarbitrary real number r and for any nonnegative integer k� we de�nethe binomial coe�cient
�rk
�by the formula�
r
k
��r�r � ��r � � � � � �r � k % �
k�
�in particular� we set�r�
�� ��� Then the function �� % xr is the
generating function of the sequence��r
�
���r�
���r�
���r�
�� � � �
�� The power
series�r�
�%�r�
�x%
�r�
�x� % � � � always converges for all jxj � ��
A proof again belongs to the realm of calculus� and it is easilydone via the Taylor series�
For combinatorial applications� it is important to note that for rbeing a negative integer� the binomial coe�cient
�rk
�can be expressed
using the �usual� binomial coe�cient �involving nonnegative integersonly�
�rk
�� ���k��rk��k
�� ���k��rk���r��
�� Hence for negative
integer powers of �� x we obtain
�
��� xn��n��n��
�%� nn��
�x%
�n�n��
�x� % � � �% �nk��
n���xk % � � � �
Note that the equality ���x � �%x%x�% � � � is a particular case for
n � ��
Operations with sequences and with their generating func
tions� To facilitate the above�mentioned process of �assembling�generating functions for given sequences� we list some importantoperations� In the sequel� let �a�� a�� a�� � � � and �b�� b�� b�� � � � besequences and let a�x and b�x be their respective generating func�tions�
�� Generating functions
A� If we add the sequences term by term� then the correspond�ing operation with generating functions is simply their addition�That is� the sequence �a�%b�� a�%b�� a�%b�� � � � has generatingfunction a�x % b�x�
B� Another simple operation is multiplication by a xed real num�
ber � The sequence �a�� a�� a�� � � � has generating function � a�x�
C� If n is a natural number� then the generating function xna�xcorresponds to the sequence
��� �� � � � � �� �z n�
� a�� a�� a�� � � ��
This is very useful for shifting the sequence to the right by arequired number of positions�
D� What do we do if we want to shift the sequence to the left� i�e�to gain the generating function for the sequence �a�� a�� a�� � � ��say� Obviously� we have to divide by x�� but we must not for�get to subtract the � initial terms �rst� The correct generatingfunction of the above sequence is
a�x� a� � a�x� a�x�
x��
E� Substituting x for x� Let be a �xed real number� and letus consider the function c�x � a�x� Then c�x is the gener�ating function of the sequence �a�� a��
�a�� � � �� For example�we know that �
��x is the generating function of the sequence of
all �s� and so by the rule just given� ����x is the generating func�
tion of the sequence of powers of �� ��� �� �� �� � � �� This operationis also used in the following trick for replacing all terms of theconsidered sequence with an odd index by �� as the reader caneasily check� the function �
��a�x % a��x corresponds to thesequence �a�� �� a�� �� a�� �� � � ��
F� Another possibility is a substitution of xn for x� This gives rise tothe generating function of the sequence whose term number nkequals the kth term of the original sequence� and all of whoseother terms are �s� For instance� the function a�x� producesthe sequence �a�� �� �� a�� �� �� a�� �� �� � � �� A more complicatedoperation generalizing both E and F is the substitution of onepower series for x into another power series� We will meet onlya few particular examples in the exercises�
���� Calculation with power series ��
Let us see some of the operations listed so far in action�
Problem� What is the generating function of the sequence
�� �� �� �� �� �� �� �� � � ��
i�e� an � �bn��c�
Solution� As was mentioned in E� the sequence �� �� �� �� � � � hasgenerating function ��� � �x� By F we get the generating function���� �x� for the sequence �� � �� � �� � � � �� and by C� the sequence � �� � �� � � � � has generating function x�� � �x�� By addition we�nally get the generating function for the given sequence� that is� theanswer is � � x��� �x�� �
G� Popular operations from calculus� di�erentiation and integration
of generating functions� mean the following in the language ofsequences� The derivative of the function a�x� i�e� a��x� corre�sponds to the sequence
�a�� �a�� �a�� � � ��
In other words� the term with index k is �k % �ak� �a powerseries is di�erentiated term by term in the same way as a poly�nomial� The generating function
R x� a�tdt gives the sequence
��� a����a��
��a��
��a�� � � �� that is� for all k � �� the term with in�
dex k equals �kak��� For instance� we can derive the power series
����� for ln��� x by integrating the function ���x �
Here is an example where di�erentiation helps�
������ Problem� What is the generating function for the sequence��� ��� ��� � � � of squares� i�e� for the sequence a�� a�� a�� � � � with ak �k � ���
Solution� We begin with the sequence of all �s with the generatingfunction �
��x � The �rst derivative of this function� ����x�� gives the
sequence �� �� �� �� � � � by G� The second derivative is ���� x�� andits sequence is � � �� � � �� � � �� � � �� again according to G� the term withindex k is k��k�� � k���� k��� But we want ak � k��
��and so we subtract the generating function of the sequence �� �� �� � � ��We thus get
ax ��
�� x�� �
�� x��
�
H� The last operation in our list is perhaps the most interesting one�multiplication of generating functions� The product a�xb�x is
�� Generating functions
the generating function of the sequence �c�� c�� c�� � � �� where thenumbers ck are given by the equations
c� � a�b�c� � a�b� % a�b�c� � a�b� % a�b� % a�b�
���
and in general we can write
ck �X
i�j�� ij�kaibj � �����
This is easy to rememberthe terms in the product a�xb�x upto the kth one are the same as in the product of the polynomials�a� % a�x% � � �% akx
k and �b� % b�x% � � �% bkxk�
Multiplication of generating functions has a combinatorial inter�pretation which we now explain in a somewhat childish example�A natural example comes in Section ����� Suppose that we have asupply of indistinguishable wooden cubes� and we know that we canbuild a tower in ai di�erent ways from i cubes� i � �� �� �� � � �� andalso that we can build a pyramid in bj di�erent ways from j cubes�j � �� �� �� � � ��
If we now have k cubes altogether� then ck � a�bk%a�bk��%� � �%akb�is the number of ways to build one tower and one pyramid at thesame time �assuming that a tower and a pyramid never have anycubes in common� In short� the generating function for the numberof ordered pairs �tower�pyramid is obtained as the product of thegenerating functions for the number of towers and for the number ofpyramids�
Remark� The operations listed above are useful not only for �nd�ing the generating function for a given sequence� but often also for
���� Calculation with power series ��
the reverse task� namely �nding the sequence corresponding to agiven generating function� In principle� the sequence can be foundby computing the Taylor series �according to Proposition ������� i�e�by a repeated di�erentiation� but in practice this is seldom a goodmethod�
We conclude this section with an example of an application ofgenerating functions� More examples are supplied in the exercises�and several more sophisticated problems follow in subsequent sec�tions�
Problem� A box contains �� red� �� blue� and �� white balls� ballsof the same color are indistinguishable� How many ways are there ofselecting a collection of �� balls from the box�
Solution� Armed with the results of Section ����� we �nd that thenumber we seek equals the coe�cient of x�� in the product
��%x%x�% � � �%x����%x%x�% � � �%x����%x%x�% � � �%x���
We need not multiply this out� Instead� we can rewrite
� % x% x� % � � �% x�� ��� x��
�� x� �����
To see this equality� we can recall a formula for the sum of the �rstn terms of a geometric series� In case we cannot remember it� we canhelp ourselves as follows� We begin with the generating function ofthe sequence ��� �� �� � � �� which is �
��x � and we subtract from it thegenerating function of the sequence
��� �� � � � � �� �z ���
� �� �� � � ��
which is x������x by item C above� The result is ���x������x�which is the generating function for the sequence
��� �� � � � � �� �z ���
� �� �� � � ��
This shows that ����� holds�
�� Generating functions
Hence we can rewrite the whole product as
�� x��
�� x� �� x��
�� x� �� x��
�� x�
�
��� x���� x����� x����� x���
The factor �� � x�� can be expanded according to the generalizedbinomial theorem ������� In the product of the remaining factors���x�����x�����x��� it su�ces to �nd the coe�cients of powersup to x��� which is quite easy� We get��
�
�
�%
��
�
�x%
��
�
�x� % � � �
���� x�� � x�� � x�� % � � ��
where the dots � � � in the second parentheses stand for powers higherthan x��� The coe�cient of x�� in this product is
�����
����������
����������
�� ��������
�� �����
Exercises
�� a Show that � � x� � x � x� � � � � � xn and � � xn�� are thesame polynomials� and deduce the formula � � x � x� � � � � � xn ��� xn����� x� For which values of x is it correct�
b Using the formula in a� show that the in�nite series ��x�x��� � �converges to �
��x for all x � ��� �� and diverges for all x outside thisinterval� This requires basic notions from calculus�
�� a Determine the coe�cient of x�� in x� � x� � x� � � � ���b Determine the coe�cient of x�� in x � x� � x� � x�� � � � ��c Determine the coe�cient of x� in �� �x���
d Determine the coe�cient of x� in �p� � x�
e Determine the coe�cient of x� in � � x������ x�
f Determine the coe�cient of x� in � � �x�p�� x�
g Determine the coe�cient of x� in �� x� �x���
�� Find generating functions for the following sequences express them ina closed form� without in�nite series��
a � � � ���� ����� ����� � � �b �� � �� � �� � � � �
c �� �� �� �� �� �� � � �
d �� �� � �� �� � �� �� � � � �
�� Find the probability that we get exactly �� points when rolling � dice�
���� Calculation with power series ��
�� Let an be the number of ordered triples i� j� k of integer numberssuch that i � j �� k �� and i��j��k � n� Find the generatingfunction of the sequence a�� a�� a�� � � � and calculate a formula for an�
�� Let an be the number of ordered r�tuples i�� � � � � ir of nonnegativeintegers with i��i�� � � ��ir � n� here r is some �xed natural number�
a Find the generating function of the sequence a�� a�� a�� � � ��
b Find a formula for an� This has been solved by a di�erent methodin Section ����
�� Solve Problem � ���� without using di�erentiation�apply the gener�alized binomial theorem instead�
�� Let an be the number of ways of paying the sum of n doublezons usingcoins of values �� �� and � doublezons�
a Write down the generating function for the sequence a�� a�� � � ��
b �Using a� �nd a formula for an reading the next section canhelp�
�� a Check that if ax is the generating function of a sequence a��a�� a�� � � � then
���xax is the generating function of the sequence of
partial sums a�� a� � a�� a� � a� � a�� � � ��
b Using a and the solution to Problem � ����� calculate the sumPnk�� k
��
c By a similar method� calculate the sumPn
k�� k��
d For natural numbers n and m� compute the sumPm
k����k�nk
��
e Now it might seem that by this method we can calculate almostany sum we can think of� but it isn�t so simple� What happens if wetry computing the sum
Pnk��
�k in this manner�
� � �Let n� r be integers with n r �� Pick a random r�element subsetof the set f�� �� � � � � ng and call it R all the �nr� possible subsets havethe same probability of being picked for R� Show that the expectedvalue of the smallest number in R is n��
r�� �
��� Calculus required �Prove the formula for the product of power series�That is� show that if ax and bx are power series satisfying theassumptions of Proposition � ����� then on some neighborhood of � thepower series cx with coe�cients given by the formula � �� convergesto the value axbx�
��� Calculus required Let ax � a�� a�x� a�x�� � � � be a power series
with nonnegative coe�cients� i�e� suppose that ai for all i� Wede�ne its radius of convergence � by setting
� � supfx � ax convergesg�a �Prove that ax converges for each real number x � � � �� andthat the function ax is continuous in the interval � � ��
�� Generating functions
b Find an example of a sequence a�� a�� a�� � � � with � � � such thatthe series a� diverges�
c Find an example of a sequence a�� a�� a�� � � � with � � � such thatthe series a� converges�
��� A warning example� calculus required De�ne a function f by
fx �
�e���x� for x �� for x � �
a �Show that all derivatives of f at exist and equal �b Prove that f is not given by a power series at any neighborhoodof �
��� Exponential generating functions In a footnote� we have de�ned theexponential generating function of a sequence a�� a�� a�� � � � as thepower series Ax �
P�i��ai�i�x
i� Here we are going to sketch somecombinatorial applications�
For a group of n people� one can consider various types of arrange�ments� For instance� one type of arrangement of n people would be toselect one of the people as a leader� and the others as a crowd� Foreach group of n people� there are n arrangements of this type� Otherexamples of types of arrangements are� arranging the n people in a rowfrom left to right n� possibilities� arranging the n people in a ringfor a folk dance there are n� �� possibilities� letting the people bejust an unorganized crowd � possibility� arranging the people intoa jury �� possibilities for n � ��� with electing one chairman� and possibilities otherwise�
a For each type of arrangement mentioned above� write down theexponential generating function of the corresponding sequence i�e� forthe sequence a�� a�� a�� � � �� where ai is the number of arrangementsof the considered type of i people�
b Let an be the number of possible arrangements of some type A fora group of n people� and let bn be the number of possible arrangementsof some type B for a group of n people� Let an arrangement of type Cmean the following� divide the given group of n people into two groups�the First Group and the Second Group� and arrange the First Groupby an arrangement of type A and the Second Group by an arrange�ment of type B� Let cn be the number of arrangements of type C fora group of n people� Check that if Ax� Bx� and Cx are the cor�responding exponential generating functions� then Cx � AxBx�Discuss speci�c examples with the arrangement types mentioned inthe introduction to this exercise�
c �Let Ax be the exponential generating function for arrangementsof type A as in b� and� moreover� suppose that a� � no empty
���� Fibonacci numbers and the golden section ��
group is allowed� Let an arrangement of type D mean dividing thegiven n people into k groups� the First Group� Second Group� � � � � kthGroup k � � �� �� � � �� and arranging each group by an arrangement oftype A� Express the exponential generating function Dx using Ax�
d �Let Ax be as in c� and let an arrangement of type E meandividing the given n people into some number of groups and organiz�ing each group by an arrangement of type A but this time it onlymatters who is with whom� the groups are not numbered� Expressthe exponential generating function Ex using Ax�
e How many ways are there of arranging n people into pairs it onlymatters who is with whom� the pairs are not numbered� Solve usingd�
��� �Using part d of Exercise ��� �nd the exponential generating functionfor the Bell numbers� i�e� the number of equivalences on n given points�Calculate the �rst few terms of the Taylor series to check the resultnumerically see also Exercise ������
��� Twelve students should be assigned work on � di�erent projects� Eachstudent should work on exactly one project� and for every project atleast � and at most � students should be assigned� In how many wayscan this be done� Use the idea of part b in Exercise ���
��� Hatcheck lady strikes again
a �Using parts a and d of Exercise ��� write down the exponentialgenerating function for arranging n people into one or several rings fora dance a ring can have any number of persons including �� Can youderive the number of such arrangements in a di�erent way�
b Consider arrangements as in a� but with each ring having at least� people� Write down the exponential generating function�
c �Using the result of b� �nd the number of arrangements of npeople into rings with at least � people each� If your calculations arecorrect� the result should equal the number of permutations withouta �xed point see Section ���� Explain why� This actually gives analternative solution to the hatcheck lady problem� without inclusion$exclusion�
���� Fibonacci numbers and the golden section
We will investigate the sequence �F�� F�� F�� � � � given by the follow�ing rules�
F� � �� F� � �� Fn� � Fn� % Fn for n � �� �� �� � � ��
�� Generating functions
This sequence has been studied by Leonardo of Pisa� called Fi�bonacci� in the ��th century� and it is known as the Fibonacci numbers�Its �rst few terms are
� �� �� �� �� �� �� ��� ��� ��� ��� ��� ���� � � � �
Fibonacci illustrated this sequence with a not too realistic example con�cerning the reproduction of rabbits in his treatise� but the sequence doeshave a certain relevance in biology for instance� the number of petals ofvarious �owers is very often a Fibonacci number� see Stewart ���� for apossible explanation� In mathematics and computer science it surfacesin various connections and quite frequently�
We show how to �nd a formula for the nth Fibonacci number us�ing generating functions� So let F �x denote the generating functionof this sequence� The main idea is to express the generating functionof a sequence whose kth term equals Fk �Fk���Fk�� for all k � ��By the relation de�ning the Fibonacci numbers� this sequence musthave all terms from the second one on equal to �� On the other hand�such a generating function can be constructed from F �x using theoperations discussed in Section ����� In this way� we get an equationfrom which we can determine F �x�
Concretely� let us take the function F �x� xF �x� x�F �x cor�responding to the sequence
�F�� F� � F�� F� � F� � F�� F� � F� � F�� F� � F� � F�� � � �
� ��� �� �� �� �� � � ��
In the language of generating functions� this means ���x�x�F �x �x� and hence
F �x �x
�� x� x�� �����
If we now tried to compute the Taylor series of this function bydi�erentiation� we wouldn�t succeed �we would only recover the def�inition of the Fibonacci numbers� We must bring in one more trick�which is well known in calculations of integrals by the name decom�position into partial fractions� In our case� this method guaranteesthat the rational function on the right�hand side of ����� can berewritten in the form
x
�� x� x��
A
x� x�%
B
x� x��
���� Fibonacci numbers and the golden section ���
where x�� x� are the roots of the quadratic polynomial ��x�x� andA and B are some suitable constants� For our purposes� a slightlydi�erent form will be convenient� namely
x
�� x� x��
a
�� ��x%
b
�� ��x� �����
where �� � �x�� �� � �
x�� a � � A
x�� and b � � B
x�� From ������ it
is easy to write down a formula for Fn� As the reader is invited tocheck� we get Fn � a�n� % b�n� �
We omit the calculation of the roots x�� x� of the quadratic equa�tion here� as well as the calculation of the constants a and b� and weonly present the result�
Fn ��p�
��� %
p�
�
�n
����p�
�
�n��
It is remarkable that this expression full of irrational numbers shouldgive an integer for each natural number n�but it does�With approximate numerical values of the constants� the formula
looks as follows�
Fn � �������� � � � ������ ��� � � �n � � ���� ��� � � �n� �
We see that for large n� the numbers Fn behave roughly as�p��n� � and
that the ratio Fn�Fn�� converges to the limit���� ���� ��� � � �� This
ratio was highly valued in ancient Greece� it is called the golden section�A rectangle with side ratio equal to the golden section was consideredthe most beautiful and proportional one among all rectangles� Usingthe picture below� you can check whether your aesthetic criteria for rect�angles agree with those of the ancient Greeks� If we cut o� a squarefrom such a golden�section rectangle� the sides of the remaining rectan�gle again determine the golden section�
Similar to the Fibonacci numbers� the golden section is encounteredsurprisingly often in mathematics�
Another derivation� a staircase� Consider a staircase with n stairs�How many ways are there to ascend the staircase� if we can climb by �stair or by � stairs in each step�
��� Generating functions
In other words� how many ways are there to write the number n as asum of �s and �s� or how many solutions are there to the equation
s� � s� � � � �� sk � n�
with si � f�� �g� i � �� �� � � � � k� k � � �� �� � � �� If we denote the numberof such solutions by Sn� we get S� � �� S� � �� and it is not di�cultto see that for n �� we have Sn�� � Sn�� � Sn think it over�� Thisimplies that Sn is exactly the Fibonacci number Fn���We derive the generating function of the sequence S�� S�� S�� � � � in
a di�erent way� According to the recipe from Section � ��� we get thatfor a given k� the number of solutions to the equation s��s��� � ��sk � nwith si � f�� �g equals the coe�cient of xn in the product x�x�k� Wecan choose k arbitrarily� however it is not prescribed by howmany stepswe should ascend the staircase� and therefore Sn is the coe�cient of x
n
in the sumP�
k��x � x�k� Thus� this sum is the generating functionof the sequence S�� S�� S�� � � �� The generating function can be furtherrewritten� the sum is a geometric series with quotient x� x� and so itequals ���� x� x�� Hence the generating function for the Fibonaccinumbers is x�� � x � x�� as we have already derived by a di�erentapproach�
Recipes for some recurrences� By the above method� one can �nda general form of a sequence y�� y�� y�� � � � satisfying the equation
yn�k � ak��yn�k�� � ak��yn�k�� � � � �� a�yn�� � a�yn � ��
for all n � � �� �� � � �� where k is a natural number and a�� a�� � � � � ak��
are real or complex numbers� For instance� for the Fibonacci numberswe would set k � �� a� � a� � �� Let us denote the set of all sequencesy�� y�� y�� � � � satisfying � �� by the symbol Y so Y depends on kand on a�� a�� � � � � ak��� This set contains many sequences in general�because the �rst k terms of the sequence y�� y�� y�� � � � can be chosenat will while all the remaining terms are determined by the relation� ��� In the sequel� we will describe what the sequences of Y looklike� but �rst we take a detour into terminology�A learned name for Eq� � �� is a homogeneous linear recurrence of
kth degree with constant coe�cients� Let us try to explain the parts ofthis complicated name�
���� Fibonacci numbers and the golden section ���
� A recurrence or recurrent relation is used as a general notion de�noting a relation usually a formula expressing the nth term of asequence via several previous terms of the sequence��
� Homogeneous appears in the name since whenever y�� y�� y�� � � � �Y then also �y�� �y�� �y�� � � � � Y for any real number �� Inmathematics� �homogeneity� usually means �invariance to scal�ing�� On the other hand� an example of an inhomogeneous re�currence is yn�� � yn � ��
� The word linear here means that the values of yj always appear inthe �rst power in the recurrence and are not multiplied together�A nonlinear recurrence is� for example� yn�� � yn��yn�
� Finally� the phrase with constant coe�cients expresses that a��a��� � � � ak�� are �xed numbers independent of n� One could alsoconsider a recurrence like yn�� � n � �yn� where the coe�cienton the right�hand side is a function of n�
So much for the long name� Now we are going to formulate a generalresult about solutions of the recurrent relation of the considered type�We de�ne the characteristic polynomial of the recurrence � �� as thepolynomial
px � xk � ak��xk�� � ak��x
k�� � � � � � a�x� a��
For example� the characteristic polynomial of the recurrence relation forthe Fibonacci numbers is x� � x� �� Let us recall that any polynomialof degree k with coe�cient � at xk can be written in the form
x� ��x� �� � � � x� �k�
where ��� � � � � �k are generally complex numbers called the roots ofthe given polynomial�
������ Proposition� Let px be the characteristic polynomial of thehomogeneous linear recurrence �������
�i� Simple roots Suppose that px has k pairwise distinct roots��� � � � � �k� Then for any sequence y � y�� y�� � � � � Y satisfying������� complex constants C�� C�� � � � � Ck exist such that for all n�we have
yn � C��n� � C��
n� � � � �� Ck�
nk �
�ii� The general case Let ��� � � � � �q be pairwise di�erent complexnumbers� and let k�� � � � � kq be natural numbers with k��k�� � � ��kq � k such that
�Another name sometimes used with this meaning is di�erence equation� Thisis related to the so�called di�erence of a function� which is a notion somewhatsimilar to derivative� The theory of di�erence equations is often analogous to thetheory of di�erential equations�
��� Generating functions
px � x� ��k�x� ��
k� � � � x � �qkq �
Then for any sequence y � y�� y�� � � � � Y satisfying ������� complex constants Cij exist �i � �� �� � � � � q� j � � �� � � � � ki � �� suchthat for all n� we have
yn �
qXi��
ki��Xj��
Cij
�n
j
��ni �
How do we solve a recurrence of the form � �� using this propo�sition� Let us give two brief examples� For the recurrence relationyn�� � �yn����yn� the characteristic polynomial is px � x���x�� �x� �x� �� Its roots are �� � � and �� � �� and Proposition � ����tells us that we should look for a solution of the form C��
n � C��n�
Being given some initial conditions� say y� � � and y� � �� we must de�termine the constants C�� C� in such a way that the formula gives theserequired values for n � � �� In our case� we would set C� � C� � ��And one more example� a quite arti�cial one� with multiple roots�
the equation yn�� � �yn�� � ��yn�� � ��yn�� � ��yn�� � �yn hascharacteristic polynomial� px � x � ��x � ��� and so Proposi�tion � ���� says that the solution should be sought in the form yn �C�� �C��n�C���
n �C��n�n �C��
�n�
��n� The values of the constants
should again be calculated according to the values of the �rst � termsof the sequence y�� y�� y�� � � ��The procedure just demonstrated for solving the recurrence � ��
can be found in all kinds of textbooks� and the generating functions areseldom mentioned in this connection� Indeed� Proposition � ���� canbe proved in a quite elegant manner using linear algebra as indicatedin Exercise ��� and once we know from somewhere that the solutionshould be of the indicated form� generating functions become unnec�essary� However� the method explained above for Fibonacci numbersreally �nds the correct form of the solution� Moreover� it is a nice ex�ample of an application of generating functions� and a similar approachcan sometimes be applied successfully for recurrences of other types�where no general solution method is known or where it is di�cult to�nd such a method in the literature� which is about the same in prac�tice�
�Of course� the authors have selected the coe�cients so that the character�istic polynomial comes out very nicely� The instructions given above for solvinghomogeneous linear recurrence relations with constant coe�cients �as well as themethod with generating functions� leave aside the question of �nding the roots ofthe characteristic polynomial� In examples in various textbooks� the recurrencesmostly have degree or �� or the coe�cients are chosen in such a way that theroots are small integers�
���� Fibonacci numbers and the golden section ���
Exercises
�� �Determine the number of n�term sequences of s and �s containingno two consecutive s�
�� Prove that any natural number n � N can be written as a sum ofmutually distinct Fibonacci numbers�
�� Express the nth term of the sequences given by the following recurrencerelations generalize the method used for the Fibonacci numbers� oruse Proposition � �����
a a� � �� a� � �� an�� � �an � �an�� n � � �� �� � � ��
b a� � � a� � �� an�� � �an�� � �an n � � �� �� � � ��
c a� � �� an�� � �an � � n � � �� �� � � ��
�� In a sequence a�� a�� a�� � � �� each term except for the �rst two is thearithmetic mean of the preceding two terms� i�e� an�� � an���an���Determine the limit limn�� an as a function of a�� a��
�� Solve the recurrence relation an�� �pan��an with initial conditions
a� � �� a� � �� and �nd limn�� an�
�� a Solve the recurrence an � an�� � an�� � � � � � a� � a� with theinitial condition a� � ��
b �Solve the recurrence an � an���an���an���an���� � ��a��a�n � with a� � a� � a� � ��
�� �Express the sum
Sn �
��n
�� �
��n� ��
�� ��
��n� ��
�� � � �� �n
�n
n
�
as a coe�cient of x�n in a suitable power series� and �nd a simpleformula for Sn�
�� CalculatePbn��c
k��
�n�kk
����k�
�� �Show that the number ��
�� �
p�n � ��p�n� is an integer for all
n ��� � �Show that the number � �
p����� has at least ��� zeros following
the decimal point�
��� �Show that for any n �� the number p���n can be written as thedi�erence of the square roots of two consecutive integers�
��� �Find the number of n�term sequences consisting of letters a� b� c� dsuch that a is never adjacent to b�
��� Generating functions
��� �Mini�Tetris� How many ways are there to �ll completely withoutoverlap an n�� rectangle with pieces of the following types� The sidesof the pieces are � and �� the pieces can be rotated by a multiple ofthe right angle� In b and c� it su�ces to calculate the generatingfunction or reduce the problem to solving a recurrence of the form� ��� and determine the order of growth an asymptotic estimate forlarge n�
a �
b � �
c �� �
��� CS This exercise is related to the theory of formal languages� We givethe necessary de�nitions but to appreciate the context� the readershould consult a textbook on automata and formal languages�
Let 0 be some �xed �nite alphabet such as 0 � fa� b� cg� A wordover 0 is a �nite sequence of letters such as babbaacccba� The emptyword having no letters is denoted by �� A language over 0 is a set ofwords over 0� If u and v are words then uv denotes the concatenationof u and v� i�e� we write �rst u and then v� The generating function ofa language L is the generating function of the sequence n�� n�� n�� � � ��where ni is the number of words of length i in L�
Let us say that a language L is very regular if it can be obtained by�nitely many applications of the following rules�
�� The languages and f�g are very regular� and the language f�gis very regular for every letter � � 0�
�� If L�� L� are very regular languages� then also the language L��L�
is very regular� where L��L� � fuv� u � L�� v � L�g��� If L is a very regular language then also L� is very regular� where
L� � f�g � L � L�L � L�L�L � � � ���� If L�� L� are very regular languages with L� � L� � � then also
L� � L� is very regular�
a Show that the following languages over 0 � fa� bg are all veryregular� the language consisting of all words of odd length� the languageconsisting of all words beginning with aab and having an even numberof letters a� and �the language consisting of all words having no twoconsecutive letters a�
b �Show that the generating function of any very regular languageis a rational function a polynomial divided by a polynomial� anddescribe how to calculate it�
c ��Show that if L�� L� are very regular languages not necessarilydisjoint ones then also L� � L� is very regular� Therefore� regularlanguages have rational generating functions�
���� Binary trees ���
d A programming project Look up information on regular lan�guages and their relation to �nite automata� Write a program thataccepts a speci�cation of a regular language by a regular expressionor by a nondeterministic �nite automaton and computes a formulafor the number of words of length n in the language�
��� �Prove Proposition � ���� by generalizing the method shown for theFibonacci numbers use a general theorem on decomposing a rationalfunction into partial fractions from integral calculus�
��� Prove Proposition � ���� directly� using linear algebra� according tothe following hints�
a Check that the set Y is a vector space with respect to compo�nentwise addition of sequences and componentwise multiplication bya complex number�
b Show that the dimension of Y equals k�c �Show that in the situation of part i of Proposition � ����� thesequences ��i � �
�i � �
�i � � � � belong to Y where i � �� �� � � � � k� and they
are all linearly independent in Y hence they form a basis of the vectorspace Y by b� This proves part i�d Verify that in the situation of part ii of Proposition � ����� eachof the sequences
�nj
��ni
�n�� belongs to the solution set Y �
e ��Prove that the sequences considered in part d are linearly in�dependent in Y � i�e� they form a basis�
���� Binary trees
We are going to consider the so�called binary trees� which are oftenused in data structures� Fig� ���� depicts several di�erent binarytrees with � vertices� For our purposes� a binary tree can conciselybe de�ned as follows� a binary tree either is empty �it has no vertex�or consists of one distinguished vertex called the root� plus an orderedpair of binary trees called the left subtree and right subtree��
Let bn denote the number of binary trees with n vertices� Ourgoal is to �nd a formula for bn� By listing all small binary trees� we�nd that b� � �� b� � �� b� � �� and b� � �� This can serve forchecking the result obtained below�
As usual� we let b�x � b�% b�x% b�x�% � � � be the corresponding
generating function� For n � �� the number of binary trees with n
�This is a de�nition by induction� First we say what a binary tree with �vertices is and then we de�ne a binary tree with n vertices using the alreadyde�ned binary trees with fewer vertices� By admitting the empty binary tree� weavoid dealing with various special cases� such as when the root has only a leftsubtree or only a right subtree�
��� Generating functions
t t ��t��t
JJt
t t ��t��tTTtt t ��t�
�t
JJt
t t��t��tTTtt t��t�
�tTTt
Fig� ���� Several di�erent binary trees on � vertices�
vertices equals the number of ordered pairs of the form �B�B�� whereB and B� are binary trees having together n� � vertices� That is� ifB has k vertices then B� has n� k � � vertices� k � �� �� � � � � n� ��Therefore� the number of such ordered pairs is
bn � b�bn�� % b�bn�� % � � �% bn��b�� �����
Comparing this with the de�nition of multiplication of power se�ries� we see that bn is exactly the coe�cient of xn�� in the productb�x�b�x � b�x�� �This is the natural example for the combinatorialmeaning of multiplication of generating functions promised in Sec�tion ����� Hence bn is the coe�cient of xn in the function xb�x��And so xb�x� is the generating function of the same sequence asb�x� except that b�x has constant term b� � � while the power se�ries xb�x� has constant term �� this is because the formula �����is only correct for n � �� We can write the following equality ofgenerating functions�
b�x � � % xb�x��
Suppose that x is such a real number that the power series b�xconverges� Then b�x is also a real number� and it must satisfy thequadratic equation b�x � � % xb�x�� By a well�known formula forthe roots of a quadratic equation� b�x must be one of the numbers
� %p�� �x
�xor
��p�� �x
�x�
This seems as if there are two possible solutions� But we know thatthe sequence �b�� b�� b�� � � �� and thus also its generating function�are determined uniquely� Since b�x is continuous as a function of x�whenever it converges� we must take either the �rst solution �the
���� Binary trees ���
one with �%� for all x� or the second solution �the one with ���for all x� If we look at the �rst solution� we �nd that for x tendingto � it goes to �� while the generating function b�x must approachb� � �� So whenever b�x converges� it must converge to the secondsolution b�x � ���p�� �x��x�
It remains to calculate the coe�cients of this generating function�To this end� we make use of the generalized binomial theorem �������This theorem gives us the expansion
p�� �x �
Xk��
���k����
k
�xk�
The coe�cient of x� is �� and hence the power series ��p�� �xhas zero constant term� We can thus divide it by �x �by shifting tothe left by one position and dividing all coe�cients by �� From thiswe get that for all n � ��
bn � ��
����n�
����
n% �
�� ������
By further manipulations� which we leave as an exercise� one canobtain a nicer form�
bn ��
n% �
��n
n
��
The numbers bn thus de�ned are known by the name Catalan num�bers in the literature and they are named after Eug1ene Charles Catalanrather than after Catalonia�Besides giving the number of binary trees� they have many other
combinatorial meanings� Some of them are indicated in the exercisesbelow�More about methods for counting various types of graphs� trees�
etc�� can be found� for example� in the book by Harary and Palmer �����Publicly available computer software which can solve many such tasksautomatically is described by Flajolet� Salavy� and Zimmermann �����together with the underlying theory�
Exercises
�� Convert the expression on the right�hand side of � �� to the formgiven below that equation�
�� �As the reader might have noticed� we have left out a discussion ofconvergence of the series bx� Prove that bx converges for some
�� Generating functions
number x �� but do not use the above�derived formula for bn sincethis was obtained under the assumption that bx converges�
�� Consider an n� n chessboard�
A
B
Consider the shortest paths from the cornerA to the cornerB followingthe edges of the squares each of them consists of �n edges�
a How many such paths are there�
b �Show that the number of paths that never go below the diagonalthe line AB is exactly bn� i�e� the Catalan number� One such path isdrawn in the �gure�
c ��Give an elementary proof of the formula bn � �n��
��nn
�� without
generating functions�
�� Consider a product of � numbers� abcd� It can be �parenthesized� in� ways� abcd� abcd� abcd� abcd� and abcd� Prove thatthe number of such parenthesizings of a product of n numbers is theCatalan number bn���
�� There are �n people standing in a queue for tickets costing � double�zons each� Everyone wants to buy one ticket� n of the people have a� �doublezon banknote and n of them a ��doublezon coin� Initially� thecashier has no money�
a How many orderings of the people in the queue are there forwhich the cashier can always give a ��doublezon coin back to each� �doublezon note owner�
b What is the probability that the cashier will be able to return cashto everyone for a random ordering of the queue�
�� �Consider a regular n�gon� Divide it into triangles by drawing n� �nonintersecting diagonals a diagonal is a segment connecting two ver�tices� Show that the number of such triangulations is bn���
�� There are �n points marked on a circle� We want to divide them intopairs and connect the points in each pair by a segment chord in sucha way that these segments do not intersect� Show that the number ofways to do this is bn�
���� Binary trees ���
�� In this exercise and several subsequent ones� we are going to use theterms rooted tree and planted tree introduced in Section ��� both aretrees with root� for planted trees the left�to�right order of sons of eachvertex is important� for rooted trees it isn�t�
a Let cn denote the number of nonisomorphic planted trees withn vertices� where each vertex either is an end�vertex or has exactly �sons examples of such nonisomorphic trees are the �rst and the thirdtrees in Fig� � ��� Show that the corresponding generating functioncx satis�es the equation cx � x � xcx�� and calculate a formulafor cn�
b �Can you derive the value of cn from the knowledge of bn thenumber of binary trees�
c Find dn� the number of nonisomorphic planted trees with n vertices�where each vertex has � �� or � sons� Note that this is somethingdi�erent from binary trees�
�� Let tn denote the number of nonisomorphic planted trees with n ver�tices�
a Show that the corresponding generating function tx satis�estx � x
��t�x� and calculate a formula for tn�
b �Can you derive the value of tn from the knowledge of bn�
� � We say that a planted tree is old if it has no young vertex� where ayoung vertex is a leaf adjacent to the root� Let sn be the number ofold planted trees with n vertices� Express the generating function sxusing tx from the previous exercise�
��� �Now let us consider rooted trees where each nonleaf vertex has exactly� sons for rooted trees� the left�to�right order of sons is immaterial�so the �rst and third trees in Fig� � �� are now isomorphic� Let ,bxbe the corresponding generating function� Derive the equation
,bx � � �x
�
�,bx� �,bx�
��
��� Consider alkane radicals� these are acyclic hydrocarbons where eachcarbon atom has � single bonds� except for one that has � single bondsand � �free� bond� Such molecules can be imagined as rooted trees�The vertices are the carbon atoms and each vertex has � �� �� or �sons� The order of sons of a vertex is not important� Let rn be thenumber of such trees with n vertices i�e� of alkane radicals with ncarbon atoms� and let rx be the generating function�
a ��Derive the equation rx � � � x
�rx� � �rx�rx � �rx�
��
b Using this equation� calculate a table of values of rn for smallvalues of n� Compare to values given in some chemistry handbook�
��� Generating functions
c CS Write a program to do the calculation in b� A more ambitiousproject is a program that calculates coe�cients of generating functionsgiven by equations of various forms�
���� On rolling the dice
Problem� We roll a die until a � appears for the �rst time� Howmany times do we need to roll� on the average�
The probability of getting a � in the �rst round is p � � � The
probability of a � not appearing in the �rst round and showing upin the second round is �� � pp� and in general� the probability of a� appearing in the ith round for the �rst time is qi � �� � pi��p�The average number of rounds �i�e� the expectation is then
S �Xi��
iqi �Xi��
i��� pi��p�
To sum this series� we introduce the generating function q�x �q�x% q�x
� % � � �� By di�erentiating this series term by term� we getq��x � � � q�%� � q�x%� � q�x�% � � �� and hence the desired S equalsthe value of q����
With some e�ort� we calculate that our generating function isgiven by the expression
q�x �p
�� p� �
�� ��� px� p
�� p�
A small exercise in di�erentiation gives q��x � p��� � �� � px��and hence S � q��� � �
p � In our case� for p � � � the average number
of rounds is thus ��
Here is a way of reasoning giving a much shorter solution� In anycase� we roll the die at least once� With probability � � p� we do notroll � in the �rst round� and then still S more rounds await us on theaverage the die has no memory� and so the situation after the �rstunsuccessful attempt is the same as if nothing happened� Therefore
S � � � �� pS�
and S � ��p results immediately�
�After some consideration� we decided on this formulation of the problem�as opposed to another one which o�ers itself� involving the so�called Russianroulette�
���� Random walk ���
The method with generating functions shown in this section hasmany applications in probability theory� If X is some random vari�able attaining value i with probability qi� i � � �� �� � � �� and if qx �P�
i�� qixi is the generating function� then the expectation of X is q���
Exercises
�� Using generating functions as we did above� calculate
a the average number of �s obtained by rolling a die n times�
b �the average value of the expression X � ��� where X is thenumber of times a die must be rolled until the �rst � appears this isa certain measure of the �typical deviation� from the average numberof rounds� in probability theory� it is called the variance�
c Let X be some random variable attaining values � �� �� � � �� where iis attained with probability qi� and let qx be the generating functionof the qi� Express the the variance of X � i�e� the quantity Var �X � �E�X �E �X ��
�� using the derivatives of qx at suitable points�
���� Random walk
Imagine the real axis drawn in the plane with integers marked bycircles� A frog leaps among these circles according to the followingrules of random walk�
� Initially �before the �rst move the frog sits at number ��
���� �
� In each move� the frog leaps either by two circles to the right�from i to i% � or by one circle to the left �from i to i� �� Itdecides on one of these possibilities at random� and both possi�bilities have the same probability �as if it tossed a fair coin anddecided according to the result heads)tails�
Problem� What is the probability that the frog ever reaches thenumber ��
First� we have to clarify what we mean by such a probability� Itis easy to de�ne the probability that the frog reaches � within the�rst � leaps� say �let us denote this probability by P�� The �rst �leaps give �� di�erent possible trajectories� since in each leap� thefrog makes a decision between two possibilities� and these decisionscan be combined arbitrarily� By the rules in our problem� all these
��� Generating functions
trajectories have the same probability� The above�de�ned probabilityP� equals the number of trajectories that pass through � �there are�� of them divided by the total number of trajectories� i�e� by ���
The probability P required in the problem can be de�ned as thelimit P � limi� Pi� where the de�nition of Pi has been explainedabove for i � �� This limit certainly exists because� clearly� P� �P� � � � ��
Let ai denote the number of trajectories of the �rst i leaps suchthat the frog reaches � by the ith leap and never before� We thushave
P �Xi��
ai�i�
If we introduce the generating function a�x � a�x%a�x�%a�x
�%� � ��we get P � a����
For solving the problem� it will be useful to look also at trajecto�ries starting at numbers other than � �but continuing according tothe same rule� For instance� what is the number bi of trajectoriesstarting at the number � that �rst reach � by the ith leap� In orderthat such a trajectory reaches �� it has to reach � �rst� Let j be thenumber of the leap by which � is �rst reached� If j is determined�there are aj possibilities to avoid � in leaps �� �� � � � � j � � and reachit by the jth leap� Then� i� j leaps remain to move from � to �� andthe number of ways for these i � j leaps is ai�j� So for a given j�there are ajai�j possibilities� and altogether we get�
bi �i��Xj��
ajai�j�
In the language of generating functions this means b�x � a�x��Analogously� let ci be the number of trajectories starting at the
number � and �rst reaching � by the ith leap� As before� we can seethat c�x � a�xb�x � a�x��
Let us investigate trajectories starting at � from a di�erent pointof view� By the �rst move � either the frog reaches � directly �whichgives a� � �� or it leaps to the number �� In the latter case� it hasci�� possibilities of reaching � for the �rst time after the next i � �
Note that we use the fact that leaps to the left are always by � and so thefrog cannot reach � from � without leaping to �rst�
���� Random walk ���
�� �� �
��
� ��
��
�
a
x
x � a�a� � �
Fig� ���� The function x � a�a� � ��
leaps� Hence for i � �� we have ai � ci��� Converted to a relationbetween the generating functions� this reads
a�x � x% xc�x � x% xa�x�� ������
In particular� for x � �� � the following equation results �where we
write P � a����
P ��
�%
�
�P ��
This has three solutions� �� ���p���� and ��
��p�%�� The negative
root can be excluded right away� The right value is given by thesecond root� P � �
� �p� � � � ����������� � � � �the golden section
again��
Why can�t � be the answer� Here is one possible argument� Sincethe series ax converges for x � �
� and since all the ai are nonnegative�ax is a nondecreasing continuous function of x on the interval � �� ��At the same time� ax has to be the root of the equation � ���� orin other words� we must have x � ax�ax� � � for all such x� Ifwe plot the function a �� a�a� � � as in Fig� � ��� we see that a �� cannot be given by the rightmost intersection of the x � �
� line withthe plotted curve since then we would have ax � � for all x slightlysmaller than �
� � This can be made rigorous by using some elementarycalculus computing the tangent to the curve at the point �� � butwe hope the picture is convincing enough�
��� Generating functions
From Eq� � ��� we could� in principle� calculate the function ax�and then try to express the numbers ai using the Taylor series� saywhich is quite laborious� A charming feature of the presented solutionis that we don�t need to do anything like that�
Exercises
�� Consider a random walk where we start at the number and in eachstep we move from i to i� � or to i� � with equal probability�a �Prove that we eventually return to with probability ��b Prove that each number k is visited at least once with probability��
�� Consider a random walk as in the preceding exercise�
a �Let Sn denote the expected number of steps needed to reach nfrom the preceding exercise� we know that n will be reached sooner orlater with probability �� What is wrong with the following argument�We claim that Sn � cn for some constant c� This is true for n � � so letn � � On the average� we need S� steps to reach �� and then Sn�� moresteps to reach n starting from �� Hence Sn � S��Sn�� � c�cn�� �cn� where c � S��
b ��What is the expected number of steps needed to get at least nsteps away from i�e� to reach n or �n�
���� Integer partitions
How many ways are there to write a natural number n as a sumof several natural numbers� The answer is not too di�cult if wecount ordered partitions of n� that is� if we regard the expressions� � � % � and � � � % � as two di�erent ways of expressing � asa sum �Exercise �� The problem becomes much harder and moreinteresting if we consider identical expressions di�ering only by theorder of addends �in this case we will simply speak of partitions of
n throughout this section� For instance� for n � �� all the possiblepartitions are � � �% �% �% �% �� � � �% �% �% �� � � �% �% ��� � � % � % �� � � � % �� � � � % �� and � � �� Let pn stand for thenumber of partitions of n in this sense�
To make the way of writing the partitions unique� we can for instanceinsist that the addends be written in a nondecreasing order� as we wrotethem in the listing of the partitions of �� So another formulation ofthe question is� how many ways are there to build a �nondecreasingwall� using n bricks� as in the following picture corresponding to thepartitions � � � � � � � � � � � and � � � � � � � � ��
���� Integer partitions ���
Such a picture is called the Ferrers diagram of a given partition�The de�nition of pn looks quite simple� but� perhaps surprisingly�
there is no �simple� formula for pn like a binomial coe�cient� say� Theproblem of estimating pn has been considered in number theory and itwas solved with an almost unbelievable accuracy by Hardy and Ra�manujan in ����� The history is described in Littlewood�s book �����which can be recommended as great reading about mathematics� Infact� Hardy and Ramanujan discovered an amazing exact and compli�cated formula for pn� Currently� proving or even understanding theseprecise results requires knowledge of quite a deep theory see e�g� An�drews �� � for a presentation� Here we will only scratch the surface ofthis problem� reasonably good asymptotic estimates for pn can be de�rived in a simple but clever way using generating functions� and this iswhat we will demonstrate�
We know how to express the number of solutions to an equationof the form
i� % i� % � � �% ik � n�
with the values of each ij lying in some prescribed set� as the coef��cient of xn in a suitable expression� Here the order of the ij doesmatter� though� so it is not obvious how to relate this to the �un�ordered partitions of n� The trick is to let ij express the contributionof the addends equal to j in a partition of n� or� in other words� thenumber of bricks in columns of height exactly j in our nondecreasingwall� Therefore� the partitions of n are in a bijective correspondencewith the solutions of the equation
i� % i� % � � � % in � n
with
i� � f�� �� �� �� � � �g� i� � f�� �� �� �� � � �g� � � � � ij � f�� j� �j� �j� � � �g�
For example� the partition � � � % � % � would correspond to thesolution i� � �� i� � �� i� � i� � i� � ��
The next step is standard� From the new formulation we imme�diately get that pn is the coe�cient of xn in the product
��� Generating functions
Pn�x � ��%x%x�% � � ���%x�%x�%x% � � � � � � ��%xn%x�n% � � �
�nY
k��
�
�� xk�
This �nite product is not the generating function of the sequencepn
�n��� To make it the actual generating function having the coef�
�cient pn at xn for all n simultaneously� we have to use the in�nite
product
P x �
�Yk��
�
�� xk�
But since an in�nite product could perhaps look more frightening westick to the �nite product Pnx in estimating pn�
Now we are going to upper�bound pn using the method alreadydemonstrated in the proof of Theorem ����� �estimating binomialcoe�cients� For all numbers x � ��� �� we have
pn � �
xnPn�x �
�
xn
nYk��
�
�� xk�
We want to choose x in such a way that the right�hand side is as smallas possible� A suitable way of estimating Pn�x is another clever partof the proof� First� for dealing with a product� it is often advisableto consider the logarithm� in our case this leads to
ln pn � ln
��
xnPn�x
�� �n lnx�
nXk��
ln��� xk�
We recall the power series ����� for logarithm�
� ln��� y �y
�%y�
�%y�
�%y�
�% � � �
for all y � ���� �� Therefore� we can write
�nX
k��
ln��� xk �nX
k��
Xj��
xkj
j�
Xj��
�
j
nXk��
xjk
�Xj��
�
j
Xk��
xjk �Xj��
�
j
xj
�� xj�
Now� perhaps unexpectedly� we use the formula for the sum of ageometric progression in a �reverse direction�� We have
���� Integer partitions ���
�� xj � ��� x�� % x% x� % � � �% xj�� � ��� xjxj��
�recall that � � x � � and so
Xj��
�
j
xj
�� xj�
Xj��
�
j
xj
��� xjxj���
x
�� x
Xj��
�
j��
Next� we need the following remarkable
� ��� Fact�Xj��
�
j����
��
As a mathematical dessert� we reproduce a proof �going back toEuler of this fact at the end of this section� Continuing with ourestimates for ln pn� we get
ln pn � �n lnx%��
�
x
�� x�
For the subsequent calculation� it is convenient to introduce a newvariable u � x��� � x �hence u can be any number in ����� andx � u��� % u� After this substitution� and using the inequalityln�� % �
u � �u �which is readily derived from Fact ������ we get
ln pn � n ln
�� %
�
u
�%��
�u � n
u%��
�u�
By substituting u �p�n�� into the last expression� we arrive at
ln pn � �q
�� n� �Why is u �
p�n�� the right value to use� A little
calculus shows that this is the value where the considered upperbound for ln pn attains its minimum as a function of u� Hence wehave proved the following�
� ��� Theorem� For all n � �� we have
pn � e�p
��n � e���������
pn�
A lower bound� How good is the upper bound just derived� The
results of Hardy and Ramanujan imply that pn � ��p�ne�p
��n� and so
the upper bound we have derived is quite good�it even has the correctconstant in the exponent� But what if we are in a wilderness in a broadsense� meaning cut o� from mathematical libraries and want to knowwhether the bound in Theorem � ���� is roughly correct� Here is a quick
�� Generating functions
way of deriving a weaker lower bound which at least tells us we are nottoo far o� the mark�As the reader is invited to calculate in Exercise �� the number of
ordered partitions on n into k addends is�n��k��
�� Since every unordered
partition with k addends gives rise to at most k� ordered partitions� wehave
pn �n��k��
�k�
n� �n� � � � � n� k � �
k��
for any k � f�� �� � � � � ng� How large should k be to give the best lowerbound� If we increase k by �� the denominator is multiplied by the factork��� and the numerator by n�k� Hence if k��� � n�k then k��is better than k� and for the best k� k � �� should be approximatelyequal to n � k� To keep the expressions simple� we set k � bpnc� Theintuition is that then n� �n� � � � � n� k�� behaves roughly likenpn� Here is a rigorous calculation supporting this intuition� We have
n� �n� � � � � n� k � � n� kk�� � nk��
��� k
n
�k��
�
and since kn � b
pnc�n � ��bpnc � �
k and �� �k
k�� � e��� we furtherget
nk��
��� k
n
�k��
nk��
��� �
k
�k��
nk
en�
By Theorem ������ we upper�bound k� � ekk�ek� and so we get
pn � n
k�
�k e�k��
nk� e�k��
n� �
e�n�e�pn�
If n is large enough then n� is much smaller than epn� and hence
n��e�pn � !e
pn� So we have shown that for n large enough� pn
lies between ec�pn and ec�
pn� where c� � c� � are suitable constants�
Such information about the order of growth of a function may often besu�cient�
Proof of Fact ������� We begin with the de Moivre formula see alsoExercise ������ cos� � i sin�n � cosn� � i sinn�� where i is theimaginary unit� i� � ��� Expanding the left�hand side by the binomialtheorem and considering only the imaginary part of both sides� we getthe identity�n
�
�sin� cosn�� ��
�n
�
�sin� � cosn�� ��
�n
�
�sin� � cosn�� �� � � �
� sinn��
Using the function cot� � cos�sin� � we can rewrite the left�hand side as
���� Integer partitions ���
sinn �
��n
�
�cotn�� ��
�n
�
�cotn�� ��
�n
�
�cotn�� �� � � �
��
From now on� let n � �m� � be odd� Then the expression in bracketscan be written as P cot� �� where P x is the polynomial
�n�
�xm ��
n�
�xm�� �
�n�
�xm�� � � � ��
We claim that the roots of P x are the m numbers r�� r�� � � � � rm�where rk � cot
� k�n � Indeed� for � �
k�n � sin� is nonzero while sinn� �
� and so P cot� � must be � Because r�� � � � � rm are all di�erent andP x has degree m� this exhausts all the roots� Therefore�
P x � nx� r�x� r� � � � x� rm�
By comparing the coe�cients of xm�� on both sides of the last equality�we �nd that nr� � r� � � � � � rm �
�n�
�� In this way� we have derived
the identitymXk��
cot�k�
�m� ��
m�m� ��
� � ���
For � � � �� � we have cot� � �� tan� � ���� and so � ��� provides
the inequalitymXk��
�m� ��
��k��
m�m� ��
ormXk��
�
k����
�
�m�m� ��m� ��
�
Letting m � � givesP�
k�� ��k� ����� An upper bound can be de�
rived similarly� Using the identity cot� � � sin�� ��� and the inequalitysin� � � valid for � � � �
� � � ��� gives
m�m� ��
�m �
mXk��
�
sin� k��m��
�
mXk��
�m� ��
��k��
which for m�� leads toP�
k�� ��k� � ����� �
Exercises
�� a Check that the number of ordered partitions of n with k summands�i�e� the number of solutions to i� � i� � � � �� ik � n with all ij �� is�n��k��
��
b Calculate the number of all ordered partitions of n� For instance�for n � � we have the � ordered partitions � � � � � � �� � � � � ��� � � � �� and � � �� Give three solutions� a �direct� combinatorialone� one based on a� and one using generating functions�
��� Generating functions
�� a CS Write a program to list all the partitions of n� each exactlyonce� This is a nice programming exercise�
b CS Write a program to compute pn for a given n� If you don�t wantto use multiple precision arithmetic� the program should at least beable to calculate pn for n up to � where pn is well below �
��� to �signi�cant digits� say� A contest can be organized for the fastest correctprogram� A consultation of the literature can give a great advantagein such a competition�
�� This time we consider the number ,pn of partitions of n with all sum�mands distinct� For instance� for n � � we only admit the partitions� � � � � and � � � � ��
a Express ,pn as a coe�cient of xn in a suitable expression�
b Following the proof method of Theorem � ����� prove that ,pn �e�pn�
c �Prove a lower bound of the form ,pn ecpn for all su�ciently
large values of n� with c � some constant� What is the largest c youcan get�
�� a Write down the generating functions for the numbers ,pn from Ex�ercise � the generating function is an in�nite product�
b Find a generating function for the numbers of unordered partitionsof n into odd summands also an in�nite product�
c �Verify that the generating functions in a and b are the same�and hence that the number of partitions into distinct summands equalsthe number of partitions into odd summands� ��Can you �nd a directargument a bijection�
�� The Royal Mint of Middle Coinland issues a� types of coins of value� doublezon� a� types of coins of value � doublezons� etc� Show thatthe number of ways of paying the sum of n doublezons by such coinsequals the coe�cient of xn in
nYi��
�
�� xiai�
�� a Express the number of nonisomorphic rooted trees of height atmost � with m leaves using the numbers pn� The notion of rootedtrees and their isomorphism are introduced in Section ���� The root isnot counted as a leaf� and the height of a rooted tree is the maximumdistance of a leaf from the root�
b This time consider rooted trees of height at most � with m vertices�Express their number using the numbers pn�
���� Integer partitions ���
c �Express the number rn of rooted trees with n leaves� all of themat height �� as the coe�cient of xn in a suitable expression possiblyinvolving the numbers pi� Exercise � can serve as an inspiration�
d ��Show that the numbers rn in c satisfy rn � eO�n� logn�� Usec and the proof of Theorem � ����� The calculation may be quitechallenging�
e �Show that the estimate in d is roughly correct� i�e� that rn ecn� logn for some constant c � �
��
Applications of linear algebra
Linear algebra is a part of algebra dealing with systems of linearequations� matrices� determinants� vector spaces� and similar things�We have already seen several proofs using linear algebra in previ�ous chapters� most notably in Section ���� Here we will demonstratefew more methods and applications� First� we present two prob�lems� one concerning the existence of so�called block designs andthe other about covering a complete graph by complete bipartitegraphs� Hardly anyone would suspect that these problems are re�lated to matrices� and yet an elegant solution can be given based onthe notion of rank of a matrix� An interested reader can �nd muchmore about similar proofs in the very vividly written textbook byBabai and Frankl ����� In the subsequent two sections of this chapter�we assign several vector spaces to each graph� this leads to a com�pact and insightful description of seemingly very complicated sets�Finally in Section ����� we consider two elegant algorithms wherelinear algebra blends with a probabilistic method�
Throughout this chapter� we assume some basic knowledge oflinear algebra� All the required material is summarized in the Ap�pendix�
���� Block designs
Here we consider very regular systems of �nite sets� the so�calledblock designs� Finite projective planes are a special case of this con�cept but the general notion of block designs no longer has a geometricmotivation�
Let V be a �nite set and let B be a system of subsets� of theset V � In order to emphasize that the set system B lives on the setV � we write it as an ordered pair �V�B� �Let us remark that such
�This notation di�ers from what we have been mostly using in previous chap�ters� but it is traditional in the theory of blocks designs�
���� Block designs ���
a pair �V�B can also be regarded as a generalization of the notionof graph� and then it may also be called a hypergraph� the points ofV are then called the vertices and the sets of B the hyperedges� Ifall the sets B � B have the same cardinality k� we say that �V�B isk�uniform�
We have already met an important example of a k�uniform set sys�tem in Chapter � on �nite projective planes� We have shown that if Vdenotes the set of points of a �nite projective plane and B stands forthe set of its lines� then the set system V�B is k � ��uniform for asuitable k� and� moreover� we have jV j � jBj � k��k��� This examplewill hopefully help also in understanding the following de�nition� whichmay look quite technical at �rst sight but we will illustrate it withseveral more examples later on�
������ De�nition� Let v� k� t� and � be integers� We suppose that
v � k � t � � and � � �� A block design of type t��v� k� � is a set
system �V�B satisfying the following conditions���� V has v elements�
��� Each set of B � B has k elements� The sets of B are called the
blocks�
��� Each t�element subset of the set V is contained in exactly �blocks of B�Here are a few basic examples illustrating this de�nition�
Example� Let V be a �nite set and k an integer� We put B ��Vk
��in words� B consists of all the k�element subsets of V � The pair�V�B is called the trivial block design�
It is easy to check that �V�B is a t��v� k� � block design� wheret � f�� �� � � � � kg can be chosen arbitrarily� v � jV j� and � �
�v�tk�t
��
�To see this� convince yourself that any t�element subset of V iscontained in exactly
�v�tk�t
�blocks B � B�
Example� Let V be a v�element set� and let k � � be an integerdividing v� Partition the elements of V into disjoint k�element subsetsB�� B�� � � � � Bv�k� and put B � fB�� B�� � � � � Bv�kg� Then �V�B is ablock design of type ���v� k� ��
Example� Let V be the set of points of a projective plane of or�der n� and let B denote the set of its lines� Such a pair �V�B is ablock design of type ���n� %n%�� n%�� �� This nontrivial fact wasproved in Section ���� Conversely� it can be shown that any block
��� Applications of linear algebra
design of type ���n�%n%�� n%�� �� for n � �� is a projective planeof order n �Exercise ��
������ Example� Let V � f�� �� �� �� �� �g and let B consist ofthe following triples� f�� �� �g� f�� �� �g� f�� �� �g� f�� �� �g� f�� �� �g�f�� �� �g� f�� �� �g� f�� �� �g� f�� �� �g� f�� �� �g� Then �V�B is a����� �� � block design� �This can be simply checked by de�nitionwith no cleverness involved�
This block design can also be de�ned in a more �structured� man�ner� Consider a cycle with vertices �� �� � � � � � and one extra vertex�� The system B then consists of all triples of vertices containingexactly one edge of the cycle� see the diagram below�
� �
�
�
�
� �
�
�
�
These examples should invoke the �correct impression that blockdesigns constitute a certain kind of regularity� Usually it is not easyto construct block designs of a given type� and the basic question inthis whole area is the question of existence�
Basic problem� For given numbers v� k� �� t� decide whether ablock design of type t��v� k� � exists or not�
Here we derive some necessary conditions by algebraic means�
At the end of this brief introduction� let us mention that block de�signs arose and are still being used in mathematical statistics in thedesign of experiments� This motivation has also in�uenced the notationintroduced above�Imagine that we want to assess several di�erent ways of treating
a certain plant for suppressing its insect parasites� say� There are vtypes of treatment to be compared v for �variety�� We will comparethe treatments by a series of experiments� and in each experiment wecan apply k types of treatment� this is given by the technical condi�tions of the experiment� Each experiment will form a block of the testedtreatments� We could in principle test all possible k�tuples� or blocks�of treatments� but in the situation of �eld experiments� this trivial wayof testing hence the name �trivial block design� is far too demandingeven for small values of k and v� For this reason� statisticians started
���� Block designs ���
using designs of experiments where one doesn�t test all possible k�tuplesbut only some selected blocks� This may of course lead to errors� sincethe experiments are incomplete� some possible blocks are not consid�ered� and hence some possible mutual in�uences of the treatments areneglected� In order to compensate for this enforced incompleteness ofthe testing� we require that at least each pair of treatments appear to�gether in the same number of experiments$blocks� The scheme of sucha series of experiments is exactly a block design of type ��v� k� �� If werequire that each triple of treatments appear in the same number� �� ofexperiments� we get a block design of type ��v� k� �� and so on�Various block designs appear under di�erent special names in the
literature� For instance� balanced incomplete block design or BIBD fordesigns of type ��v� k� �� Steiner systems for � � �� tactical con�gu�rations for t � �� etc�
Integrality conditions� It should be clear that a block designof type t��v� k� � doesn�t exist on each set� i�e� for all values of v�For instance� a ���v� k� � design is a partition into k�element sets�and hence v has to be divisible by k� Another� less trivial exampleis obtained for the case of projective planes� where v is determineduniquely by the size of the lines� The following theorem describes themost important class of necessary conditions for the existence of ablock design of type t��v� k� ��
������ Theorem �Integrality conditions�� Suppose that a block
design of type t��v� k� � exists� Then the following fractions must be
integers�
�v�v � � � � � �v � t% �
k�k � � � � � �k � t% �� �
�v � � � � � �v � t% �
�k � � � � � �k � t% �� � � � � �
v � t% �
k � t% ��
Proof� This is an application of double�counting� Let �V�B be ablock design of type t��v� k� �� Fix an integer number s with � �s � t and an s�element set S � V � Let us count the number N ofpairs �T�B with S � T � �V
t
�and T � B � B�
VB
TS
On the one hand� T can be picked in�v�st�s
�ways� and each T is a
subset of exactly � blocks B � B� hence N � ��v�st�s
��
��� Applications of linear algebra
On the other hand� let M be the number of blocks containing theset S� Since each block B containing S contains
�k�st�s
�t�element sets
T with S � T � we also have N � M�k�st�s
�� Hence
M � �
�v�st�s
��k�st�s
� � ��v � s � � � �v � t% �
�k � s � � � �k � t% ��
and so the fraction on the right�hand side has to be an integer as thetheorem asserts� �
Remark� By considering the above proof for s � and for s � �� we
see that � v�v�������v�t���k�k�������k�t��� determines the total number of blocks and
� �v�������v�t����k�������k�t��� is the number of blocks containing a given element x �
V � i�e� the �degree of x�� In the statistical interpretation explainedabove� this number expresses the number of times the treatment x hasbeen applied� and it is usually denoted by r for �repetitions��
������ Example �Steiner triple systems�� The ��rst� nontriv�ial example of a block design of type t��v� k� � is obtained for t � ��� � �� and k � �� This is a system of triples where each pair ofpoints is contained in exactly one triple� In other words� it is a wayof covering all edges of a complete graph by edge�disjoint triangles�
In this case� the integrality conditions from Theorem ������ re�quire that the numbers
v�v � �
�and
v � �
�
be integers� From this� it is easy to derive that either v � � �mod �or v � � �mod �� Hence v has to be one of the numbers �� �� �� ������ ��� ��� ��� ��� � � �� For all such values of v� a block design of type���v� �� � exists� Such designs are called Steiner triple systems �seeExercise �� For v � �� a Steiner triple system is a projective planeof order � �the Fano plane� For v � �� we have the following Steinersystem�
���� Fisher�s inequality ���
This can be regarded as an a�ne plane� which arises from a pro�jective plane of order � by deleting one line and all its points �seeExercise �������
Balanced incomplete block designs� For t � � i�e� if we requirethat each pair is in exactly � k�tuples from B� the integrality conditionslook as follows�
�vv � � � �mod kk � ��
�v � � � mod k � �� ����
These conditions are no longer su�cient in general� But the followingdi�cult and important result holds�
������ Theorem Wilson�s theorem� For any choice of numbersk � and � �� there exists a number v�k� � such that for allv v�k� � satisfying the integrality conditions ������� a block designof type �v� k� � exists�
In other words� the integrality conditions are also su�cient for t � �if the ground set is large enough� The theorem says nothing about smallvalues of v� for instance� about the existence of block designs of type��k� � k � �� k � �� �� i�e� of �nite projective planes�We have mentioned this theorem for completeness� and we are not
going to prove it here a proof can be found in Beth� Jungnickel� andLenz �����
Exercises
�� a Verify that a projective plane of order q is a block design of type��q� � q � �� q � �� ��
b �Show that� conversely� any block design of type ��q��q��� q��� �is a projective plane of order q�
�� �Show that any block design of type ��q�� q� � for q � is as a�neplane of order q see Exercise ����� for the de�nition�
�� Construct a Steiner triple system with �� elements�
�� �Put n � �m� where m is an odd natural number� We de�ne a setsystem X�M as follows� X � fx� i� i � �� �� �� x � � �� � � � �m��g�andM consists of all triples fx� �� x� �� x� �g and all triples of theform fx� i� y� i� z� i� �g� where x �� y� x � y � �z mod m� andi � �� �� �� Prove that X�M is a Steiner triple system�
���� Fisher�s inequalityOne of the founders of the theory of block designs was an English statis�tician� R� A� Fisher� Although examples of block designs have been
�� Applications of linear algebra
known for a long time Steiner triple systems for almost � years�Fisher was the �rst to identify the general de�nition and its signi�cancein the statistical context� He also found additional necessary conditionsrestricting the existence of block designs�
������ Theorem �Fisher�s inequality�� Let �V�B be a blockdesign of type ���v� k� � with v � k� Then jBj � jV j� Hence� thedesign of tests for v treatments requires at least v experiments�
Note that block designs with jBj � jV j exist �for example� the�nite projective planes� and so� in this sense� Fisher�s inequality isoptimal� The following example illustrates its strength�
Example� Fisher�s inequality implies that there is no block designof type ������ �� �� Indeed� by the remark following Theorem �������the number of blocks in such a design must be ����
�� � � � ��� Atthe same time� the integrality conditions are satis�ed for this choiceof parameters� we have already veri�ed that the number of blocksis integral� and also the number r � ��
� � � is an integer� Thereader may check that block designs of type ������ �� � and of type������ ��� � are excluded by Fisher�s inequality as well� although theyagain satisfy the integrality conditions�
Fisher�s inequality can be proved by a remarkable applicationof elementary linear algebra� as was discovered by an Indian mathe�matician R� C� Bose� Before we begin with the proof� let us introducethe incidence matrix of the set system �V�B� this is a similar con�cept to the incidence matrix of a graph �for oriented graphs it wasdiscussed in Section ���� Let us denote the elements of the set Vby x�� x�� � � � � xv and the sets of B by B�� B�� � � � � Bb� We de�ne av b matrix A � �aij� with rows corresponding to points of V andcolumns to sets of B� by the formula
aij �
�� if xi � Bj
� otherwise�
The matrix A is called the incidence matrix of the set system �V�B�Proof of Fisher�s inequality� For a given block design �V�B�consider its incidence matrix A � �aij� The matrix transposed toA� AT � has size b v� and hence the matrix product AAT has sizev v� We show that the matrix M � AAT has a very simple form�
���� Fisher�s inequality ���
Let us consider an entry mij of M � By the de�nition of matrixmultiplication� we have
mij �bX
k��
aikajk
�the term in the jth column and kth row of the matrix AT is ajk�Thus� the entry mij expresses the number of sets Bk containing bothxi and xj � By the de�nition of a block design� mij can only attaintwo possible values�
mij �
�� for i � j� v��k�� for i � j�
The number � � v��k�� has been denoted by r in the preceding text� andso the matrix M is �
BBBBr � � � � �� r � � � ����
���� � �
���� � � � � r
CCCCA �
We want to show that this matrix is regular� i�e� that its determinantis nonzero� Elementary row operations give
detM � det
�BBBB
r % �v � �� r % �v � �� � � � r % �v � ��� r � � � ����
���� � �
���� � � � � r
CCCCA
�
�r % �v � ��
�det
�BBBB
� � � � � �� r � � � ����
���� � �
���� � � � � r
CCCCA
�
�r % �v � ��
�det
�BBBB
� � � � � �� r � � � � � ����
���� � �
���� � � � � r � �
CCCCA
� �r % �v � �� � �r � �v���
We now recall that r � � � v��k�� � Clearly� r % �v � �� � �� and sincev � k� we also have r � �� and so detM � �� Therefore� the matrix
��� Applications of linear algebra
M has rank� v� But if we had b � v then the rank of both the matricesA and AT would be strictly smaller than v� and consequently alsothe matrix M � AAT would have rank � v �here we use a simpleproperty of matrix rank� see Exercise �� We conclude that b � v�This �nishes the proof of Fisher�s inequality� �
This application of matrix rank became the basis of many similar�and important proofs in combinatorics� Another proof of the factthat r�M � v is indicated in Exercise ��
Exercises
�� For � � �� prove Fisher�s inequality directly without using linearalgebra�
�� Show that if A is an n�k matrix and B a k�m matrix then rAB �maxrA� rB�
�� �Let F be some �eld and G � F some sub�eld of F you may wantto imagine the real numbers for F and the rationals for G� Let A bea matrix with elements from the �eld G� The rank of A can be con�sidered over the �eld G with the linear dependencies in the de�nitionhaving coe�cients in G or over the �eld F linear dependence withcoe�cients in F � Explain why we obtain the same rank in both cases�
�� A square n � n real matrix M is called positive de�nite if we havexTMx � for each nonzero column vector x � Rn�
a Why does any positive de�nite n�nmatrixM have the full rank n�
b Show that the matrix M used in the proof of Fisher�s inequalityin the text is positive de�nite and hence it has rank v� without acalculation of the determinant�
�� a Let C�� C�� � � � � Cm be subsets of an n�element set X � Supposethat each Ci has an odd cardinality� and that the cardinality of eachintersection Ci � Cj for i �� j is even� Prove that then m � n� Lookat the matrix ATA� where A is the incidence matrix of the consideredset system� but work over the ��element �eld i�e� modulo ��
�Let us recall that the rank of a matrix M � usually denoted by the symbolr�M�� is the maximum possible number of linearly independent rows in M � Therank can also be de�ned analogously using the columns instead of the rows� anda basic linear algebra theorem tells us that both de�nitions always yield the samenumber�
���� Covering by complete bipartite graphs ���
b Consider a similar problem as in a� but this time we require thatthe sizes of the sets themselves be even while all jCi � Cj j be odd fori �� j� Prove that m � n again holds�
c �And this time we require that the sets Ci all be distinct� and theirsizes and the sizes of all pairwise intersections be even� Show that onecan construct such a system with �bn��c sets�
�� Generalized Fisher�s inequality Let X be an n�element set� and letq be an integer number� � � q � n� Let C�� C�� � � � � Cm be subsetsof X � and suppose that all the intersections Ci � Cj for i �� j havecardinality exactly q�
a �Using the method of Exercise �� prove that m � n� Treat thecase when jCij � q holds for some i separately�
b �Why can the claim in a be called a �generalized Fisher�s in�equality�� Derive Fisher�s inequality from it�
���� Covering by complete bipartite graphs
The following question has been motivated by a problem in telecom�munications�
Problem� The set of edges of a complete graph Kn should beexpressed as a disjoint union of edge sets of m complete bipartitegraphs� What is the smallest value of m � m�n for which this ispossible�
One possible way of expressing E�Kn as a disjoint union of edgesets of n � � complete bipartite graphs uses graphs of type K��ni
��stars�� Here is such a disjoint covering for n � ��
�
� �
�
�
To produce such a disjoint covering for an arbitrary n� suppose thatE�Kn�� has already been expressed using n� � stars� In the graphKn� consider one vertex� and cover all edges containing that vertexby the edge set of a star K��n��� Then it remains to cover all edgesof a graph isomorphic to Kn��� and we can already do this�
It is not at all obvious that we couldn�t do better� say by usingsome complete bipartite graphs both of whose color classes are large�
��� Applications of linear algebra
But Graham and Pollak discovered an ingenious way of showing thatno better disjoint covering may exist�
������ Theorem �Graham�Pollak theorem�� We have m�n �n� ��
Proof� Suppose that complete bipartite graphs B�� B�� � � � � Bm dis�jointly cover all the edges of Kn� i�e� we have V �Bk � V �Kn �f�� �� � � � � ng and E�Kn � E�B� &�E�B� &� � � � &�E�Bm� Let Xk andYk be the color classes of Bk� this means that the edges of Bk all gobetween Xk and Yk�
To each graph Bk� we assign an n n matrix Ak� whose entry inthe ith row and jth column is
a�k ij �
�� if i � Xk and j � Yk� otherwise�
The de�nition of Ak resembles the adjacency matrix of the graphBk� except for the fact that Ak is not symmetriceach edge of thegraph Bk only contributes one �� For example� for the subgraph
�
� �
�
�
�
Xk
YkBk �
the matrix Ak is �BBBBBBB
� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �� � � � � �
CCCCCCCA�
We claim that each of the matrices Ak has rank �� This is because allthe nonzero rows of Ak equal the same vector� namely the vector with�s at positions whose indices belong to Yk and with �s elsewhere�
Let us now consider the matrix A � A� % A� % � � � % Am� Eachedge fi� jg belongs to exactly one of the graphs Bk� and hence foreach i � j� we have either aij � �� aji � �� or aij � �� aji � ��where aij denotes the entry of the matrix A at position �i� j� We
���� Covering by complete bipartite graphs ���
also have aii � �� From this we get A % AT � Jn � In� where Jn isthe n n matrix having �s everywhere and In is the n n identitymatrix� with �s on the diagonal and �s elsewhere� We now want toshow that the rank of such a matrix A is at least n � �� Once weknow this� we get n� � � r�A � r�A� % � � �% r�Am � m� becausefor arbitrary two matrices M� and M� �of the same shape we haver�M�%M� � r�M�%r�M�� this is easy to check from the de�nitionof matrix rank �Exercise ��
For contradiction� let us suppose that r�A � n� �� If we add anextra row consisting of all �s to the matrix A� the resulting �n%�nmatrix still has rank� n��� and hence there exists a nontrivial linearcombination of its columns equal to the zero vector� In other words�there exists a �column vector x � Rn� x � ��� �� � � � � �T � such thatAx � � and also
Pni�� xi � ��
From the last mentioned equality� we get Jnx � �� We calculate
xT�A%AT
�x � xT �Jn � Inx � xT �Jnx� xT �Inx
� �� xTx � �nXi��
x�i � ��
On the other hand� we have
xT�AT %A
�x �
�xTAT
�x% xT�Ax � � � x% x � � � ��
and this is a contradiction� Hence r�A � n� � and Theorem ������is proved� �
Exercises
�� Let M� and M� be two n � m matrices� Check that rM� �M� �rM��rM�� and show with examples that sometimes equality holdsand sometimes not�
�� a The edges of Kn should be covered by edges of complete bipartitesubgraphs of Kn� but we do not insist on their edge sets being disjointi�e� one edge may be covered several times� Show that there exists acovering consisting of dlog� ne bipartite graphs�b �Prove that a covering as in a really requires at least dlog� nebipartite graphs�
�� �This time� we want to cover all the edges of Kn by edges of completebipartite subgraphs� in such a way that each edge is covered an odd
��� Applications of linear algebra
number of times� Prove that we need at least �� n � � complete bi�
partite subgraphs� Proceed similarly as in the proof in the text� butwork with matrices over the ��element �eld� Instead of the matrix Ak�consider the adjacency matrix of the graph Bk� whose rank is ��
�� �In an ice�hockey tournament� each of n teams played against everyother team� with no draws� It turned out that for every nonemptygroup G of teams� a team exists it may or may not belong to G thatwon an odd number of games with the teams of G� Prove that n iseven� Hint� Work with a suitable matrix over the ��element �eld�
���� Cycle space of a graphLet G � V�E be an undirected graph� Let the symbol KG denote theset of all cycles� of all possible lengths� in the graph G more exactly�the set of all subgraphs that are cycles� It is clear that this set deservesa complicated notation by a calligraphic letter since it is quite large�Check that� for instance� for the complete graph Kn we have
jKKnj �
nXk��
�n
k
�� k � ��
�� ����
and for the complete bipartite graph Kn�n we get
��KKn�n
�� � nXk��
�n
k
��
� k�k � ���
� ����
On the other hand� we may note that KG � if and only if G is a foresta disjoint union of trees�It might seem that the set KG has no reasonable structure� In this
section� we introduce a suitable generalization of the notion of a cyclerelated to the material explained in Section ��� on Eulerian graphswhich extends the set of all cycles to a larger set with a very simplestructure� namely with the structure of a vector space� Ideas presentedin the sequel originally arose in the investigation of electrical circuits�
������ De�nition �Even set of edges�� Let G � �V�E be an
�undirected� graph� A set E� � E is called even if the degrees of all
vertices in the graph �V�E� are even�
For example� the empty set and the edge set of an arbitrary cycleare even sets�
In the sequel� it will be advantageous to identify a cycle with itsedge set�
������ Lemma� A set E� of edges is even if and only if pairwise
disjoint cycles E�� E�� � � �� Et exist such that E� � E� &�E� &� � � � &�Et�
���� Cycle space of a graph ���
Proof� If E� is a nonempty even set then the graph �V�E� is not aforest and hence it contains some cycle� E�� The set E� nE� is againeven� and so we can proceed by induction on the number of edgesin E�� �
We now describe the structure of the family of all even sets ofedges in a given graph G � �V�E algebraically� We denote theedges of G by e�� e�� � � � � em� and to each set A � E� we assign itscharacteristic vector vA � �v�� v�� � � � � vm de�ned by
vi �
�� if ei � A� otherwise�
The vectors are added and multiplied modulo � �which means that� % � � �� Let A�B � E be even sets� Then the reader should beable to check without di�culties that
vA % vB � vC �
where C � �A �B n �A B is the symmetric di�erence of the setsA and B�
Let the symbol E denote the set of the characteristic vectors ofall even sets of edges in G� For an easier formulation� we need togeneralize the notion of a spanning tree a little� by a spanning forestof an arbitrary� possibly disconnected� graph G we understand anysubgraph �V �G� +E of G containing no cycles and inclusion maximalwith respect to this property �i�e� adding any edge of G to +E createsa cycle� For a connected graph G� this de�nition coincides with thede�nition of a spanning tree in Section ���� For a disconnected graphwe get a forest consisting of spanning trees of all the components�
������ Theorem �Cycle space theorem��
��� For any graph G� the set E is a vector space over the ��element
�eld GF ��� The dimension of this vector space is jEj � jV j% k�where k is the number of components of the graph G�
��� Fix an arbitrary spanning forest T � �V�E� of the graph G�and for each edge e � E n E�� let Ce denote the �unique� cycle
contained in the graph �V�E� � feg� Then the characteristic
vectors of the cycles Ce� e � E n E�� form a basis of E �In this theorem� the symbol GF �� stands for the ��element �eld
consisting of the numbers � and �� with arithmetic operations per�formed modulo �� The letters GF come from �Galois �eld�� which
��� Applications of linear algebra
is a traditional term for a �nite �eld� A vector space over GF ��simply means that if the characteristic vectors of two even sets areadded modulo � we again obtain a characteristic vector of an evenset�
The cycle Ce is called an elementary cycle �determined by theedge e� with respect to a given spanning forest�
Proof� First we show that E is a vector space� To this end� we haveto check that by adding two vectors from E we again get a vectorfrom E � and by multiplying a vector from E by a number from the�eld GF �� we also get a vector from E � The latter is rather trivial�since we can only multiply by � �getting �vA � v� or by � �andthen �vA � vA� According to the remark above the theorem� theaddition of vectors corresponds to taking the symmetric di�erenceof the respective sets� and so it su�ces to show that the symmetricdi�erence of two even sets A and B is again an even set� Let us pickan arbitrary vertex v � V � Suppose that dA of the edges incident tov belong to A� dB of them belong to B� and d of them belong to bothA and B� Here dA� dB are both even numbers� The number of edgesincident to v belonging to the symmetric di�erence �A�Bn �ABis dA%dB��d� and hence the degree of v in the symmetric di�erenceis even� Therefore� the symmetric di�erence is an even set and so Eis a vector space over GF ���
Let �V�E� be a spanning forest of the graph G� Then jE�j �jV j�k� where k is the number of components of the graph G� It suf��ces to prove that the characteristic vectors of all elementary cyclesconstitute a basis of the vector space E �
We �rst show that the elementary cycles are linearly independent�Consider an edge ei � E�� The characteristic vector of the elemen�tary cycle Cei is the only one among the characteristic vectors of allelementary cycles having � at position i� For this reason� a charac�teristic vector of an elementary cycle cannot be a linear combinationof other such vectors�
Next� let us show that the elementary cycles generate E � Choosean even set A and de�ne a set B by giving its characteristic vector�
vB �X
e�AnE�vCe �
Which edges are contained in B� These are exactly the edges be�longing to an odd number of elementary cycles �with respect to the
���� Cycle space of a graph ���
spanning forest �V�E�� Surely B does contain the set AnE� becauseeach of its edges lies in a unique elementary cycle� Let C denote thesymmetric di�erence of the sets A and B� This is an even set� and atthe same time� it must be contained in E�� Since E� has no cycles� weget that C � �� which means that A � B� We have thus expressedthe set A as a linear combination of elementary cycles� �
Example� Let us consider the following graph G � �V�E�
a
i
b c
d e f
g h
��
�
��
�
The dimension of its cycle space is � � � % � � �� If we choose thespanning tree drawn by thick lines� then the corresponding basis ofthe cycle space consists of the characteristic vectors of the followingelementary cycles�
Ca � fa� b� cgCd � fb� e� h� i� dgCg � fg� h� igCf � fc� f� h� eg�
For example� for the cycle C � fa� f� i� dg� we have the expressionvC � vCa % vCd
% vCf�
We easily obtain the following consequence of Theorem �������
������ Corollary� The number of even sets of a graph G � �V�Ewith k components is �jEj�jV jk�
In spite of the large number of even sets� their structure is simple andthey can be easily generated from a much smaller basis� The dimensionof the cycle space� i�e� the number jEj� jV j�k� is called the cyclomaticnumber of the graph G � V�E� Also the older name Betti number issometimes used� This is related to a topological view of a graph�
Exercises
�� Verify the formulas ���� and �����
�� Applications of linear algebra
�� Prove Corollary �������
�� Determine the cyclomatic number of an m�n grid graph� for example�
�� �
�� Prove that for any topological planar ��connected graph i�e� a planar��connected graph with a �xed planar drawing� the border cycles ofthe bounded faces form a basis of the cycle space E �
���� Circulations and cuts� cycle space revisitedIn this section� we put the material of the previous section into a some�what di�erent perspective� We will express things using matrices� andwe will work with both undirected graphs and their orientations� In thismore complicated setting� a cycle space theorem similar to ������ willappear in new connections�
Circulations� Let us recall the notion of an orientation from Sec�tion ���� An orientation of a graph G � V�E is a directed graph�G � V� �E� where the set �E contains� for each edge fx� yg � E� exactlyone of the directed edges x� y and y� x� The following picture showsa graph and one of its possible orientations�
G �G
� �
� �
The number of all possible orientations of a graph G is �jEj� but manyof them can be isomorphic�
We assume that some orientation �G � V� �E has been chosen once
and for all� A real function f � �E � R is called a circulation if we have�for each vertex v of the graph G�X
xV� �v�x�Efv� x �
XxV� �x�v�E
fx� v� ����
Let us remark that a circulation may also attain negative values onsome edges� The set of the undirected edges e with f�e �� � where �e
��� Circulations and cuts� cycle space revisited ���
is the chosen orientation of e� is called the carrier of f � It is easy to seethat the carrier of any nonzero circulation contains a cycle but here itis important that we work with an orientation of an undirected graph�i�e� that edges x� y and y� x never occur simultaneously�The notion of a circulation has various intuitive interpretations� For
example� if �G is a design of an electrical circuit and if fe expresses thecurrent �owing through an edge e� then Eq� ���� says that for eachvertex� the amount of current �owing in is the same as the amount �ow�ing out� This is the �rst Kirchho� law� This �electrical� interpretationwas one of the �rst motivations for the theory discussed in this section�One example of a circulation can be obtained as follows� Let C �
v�� v�� � � � � vk�� � v� be the sequence of vertices of an undirected
cycle in the graph G� We de�ne a circulation f in the orientation �G byputting
fvi� vi�� � � if vi� vi�� � �E
fvi��� vi � �� if vi��� vi � �Efx� y � if fx� yg is not an edge of C�
We say that this circulation belongs to the cycle C� Note that it dependsof the direction in which the edges of the undirected cycle C were listed�For the graph in the preceding picture and for the cycle with the vertices�� �� �� � in this order� the circulation looks as follows�
� �
� �
�
��
�
��
It is easy to see that if f� and f� are circulations� then the functionf� � f� is a circulation on �G as well� For a real number c� the functioncf� is also a circulation� In both cases� it su�ces to check the condition����� Hence the set of all circulations has the structure of a vectorspace� This time it is a vector space over the real numbers� Let us denotethis vector space by C and call it the circulation space of G�It can be shown that for any graph G� the circulation space C is
generated by circulations belonging to cycles in G see Exercise ��Soon we will obtain a more exact information about the structure of C�Potentials and cuts� Let p�V � R be an arbitrary function p for
potential� We de�ne a function p on the set of directed edges of �G bythe formula
px� y � px� py ����
for each directed edge x� y � �E�
��� Applications of linear algebra
The function p� �E � R is called a potential di�erence anyoneremembering a little of physics can probably see a relation to electricalcircuits� Each function g� �E � R for which a potential p exists withg � p is also called a potential di�erence�It is easy to verify that the sum of two potential di�erences is a po�
tential di�erence� and similarly for multiplying a potential di�erence bya real number� Let us denote the vector space of all potential di�erencesby R and call it the cut space�Why did we choose this name� Let us consider the following sit�
uation� Let a potential p attain the values and � only� Let us putA � fv � V � pv � �g� B � V n A� Then the potential di�erenceg � p is nonzero only for the directed edges with one vertex in A andthe other vertex in B�
gx� y � � for x � A� y � Bgx� y � �� for x � B� y � Agx� y � otherwise�
It is natural to call the set of all edges going between A and B a cut�because the number of components increases by its removal assumingthat there is at least one edge between A and B� In this picture� wehave indicated a potential p
�
�
��
��
����
and its potential di�erence� The edges of the corresponding cut aredrawn bold�We now describe the whole situation using the incidence matrix� To
this end� we number the vertices� V � fv�� � � � � vng� and the edges� E �fe�� � � � � emg� The symbol �ei denotes the directed edge corresponding tothe edge ei in the orientation �G� From Section ��� we recall the incidencematrix of the orientation �G� This matrix� D� has size n � m� and itsentry dik is de�ned by the following rule�
dik �
����� if vi is the tail of �ek� if vi is the head of �ek otherwise�
The following elegant description of the circulation space and of the cutspace can be given�
��� Circulations and cuts� cycle space revisited ���
������ Theorem� For any graph G� the cut space R is generated bythe rows of the incidence matrix D� The circulation space C is theorthogonal complement of the cut space R� i�e� C � fx � Rm� xT y � for all y � Rg�Proof� Let D � dij be the n � m incidence matrix� It is easy tosee that each row is a potential di�erence the corresponding potentialhas a � sitting at the row�s vertex and elsewhere� Next� consider anarbitrary potential di�erence g � p� For a directed edge �ej � vr� vs�we have g�ej � pvr�pvs �
Pni�� dijpvi� this follows by comparing
Eq� ���� to the de�nition of the incidence matrix� Hence� if we regardthe function g as a row vector� it is a linear combination of the rows ofthe incidence matrix� Therefore� the rows generate the cut space R�Let us now rewrite the condition ���� for a circulation f using the
incidence matrix� From the equalityXxV� �x�v�E
fx� v �X
xV� �v�x�Efv� x
we get X�x�v�E
fx� v�X
�v�x�Efv� x � �
For v � vi� this can also be written as
mXj��
f�ejdij � �
The function f � regarded as an m�element vector� thus has a zero scalarproduct with the ith row of the matrix D� So f is orthogonal to eachrow of D� actually� we see that the orthogonality of f to all rows of D isequivalent to f being a circulation� Therefore� the vector spaces C andR regarded as subspaces of the spaceRm are orthogonal complementsof each other� �
What is the dimension of the cut space R� By the previous theorem�this is the dimension of the space generated by the rows of the incidencematrix D� By a basic result of linear algebra we have used several timesalready� this is the same as the dimension of the space generated by thecolumns of D� and this dimension we are now going to determine�Let dj denote the jth column of D corresponding to the directed
edge �ej�Let us consider some set J � f�� �� � � � �mg of column indices� and
let us ask when the set of columns fdj � j � Jg is linearly dependent�A linear dependence means that there exist numbers cj � j � J � notall of them zero� such that
PjJ cjdj is the zero n�element vector� Let
��� Applications of linear algebra
us write this out for each component separately� The ith component�corresponding to the vertex vi� givesX
jJcjdij � �
If we de�ne ct � for t �� J � we get the condition ���� from the de�ni�tion of a circulation� and so c � c�� c�� � � � � cm is a nonzero circulation�Hence the carrier of c contains a cycle see Exercise ��On the other hand� as we already know� for each cycle C there exists
a nonzero circulation with carrier C� Altogether we get that the set ofcolumns fdj � j � Jg is linearly independent if and only if the edge setfej � j � Jg contains no cycle� Hence the rank of the matrix D is n� k�where k is the number of components of the graph G� We have proved�
������ Theorem� For a graph G with n vertices� m edges� and k components� the cut space R has dimension n�k and the circulation spaceC has dimension m� n� k�
This can be regarded as a more sophisticated version of Theorem ������over the �eld of real numbers�The relation of the even sets of edges and the cuts� or of the circu�
lations and the potential di�erences� has the nature of a duality� Theconsiderations above can also be extended to other combinatorial ob�jects than graphs� This is considered in the so�calledmatroid theory seeOxley ����� for instance�
Exercises
�� De�ne an �elementary circulation with respect to a given spanning for�est�� Show that such elementary circulations generate the circulationspace�
�� a Let f � �E � R be a nonzero circulation on an orientation �G of anundirected graph G� Prove that the carrier of f contains a cycle�
b True or false� The carrier of any circulation is a even set of edges�
���� Probabilistic checking
Checking matrix multiplication� Multiplying two square matri�ces is a very important operation in many applications� A straight�forward algorithm multiplying two n n matrices according to thede�nition of matrix multiplication requires about n� arithmetic op�erations� But� quite surprisingly� ingenious algorithms have been dis�covered that can do such a multiplication in an asymptotically muchbetter time� You can read about such algorithms in Aho� Hopcroft�and Ullman ���� for instance� The current asymptotic record is an
���� Probabilistic checking ���
algorithm executing only O�n���� operations� Because of a reallyhuge constant hidden in the O� notation� this algorithm is onlytheoretically interesting�
But what is a theory today may enter the commercial sector to�morrow� and so you can imagine that a software company sells a pro�gram called MATRIX WIZARD and claims it can multiply squarematrices at a lightning speed� However� since your matrix multipli�cation application is quite critical and wrong results could be disas�trous� you would like to be sure that MATRIX WIZARD multipliesmatrices not only fast but also correctly� You can test it on manyexamples� but even if it succeeds on many test examples this doesn�tnecessarily mean it�s always correct� It would be most satisfactoryto have a simple checking program appended to MATRIX WIZARDthat would always check whether the resulting matrix� C� really isthe product of the input matrices A and B� Of course� a checking pro�gram that would actually multiply A and B and compare the resultwith C makes little sense� you don�t know how to multiply matri�ces as quickly as MATRIX WIZARD does and so all the advantagesfrom its fast multiplication would be lost� But it turns out that ifwe allow some slight probability of error in the checking� there reallyis a very simple and e�cient checker for matrix multiplication� Forsimplicity� we assume that the considered matrices consist of ratio�nal numbers� although everything works without change for matricesover any �eld�
������ Theorem �Freivalds� matrix multiplication checker��There exists a randomized algorithm which for any three input nnmatrices A�B�C with rational entries performs O�n� arithmetic op�
erations and answers either CORRECT or INCORRECT� If A�B�Care such that AB � C then the algorithm always says CORRECT�
If� on the other hand� AB � C� then the algorithm answers INCOR�
RECT with probability at least �� � for any given A�B�C�
By a randomized algorithm� we mean an algorithm that maymake some of its decisions at random� We may imagine that at somesteps� it �tosses a coin� and chooses one of two possible continuationsaccording to the result heads)tails�
In real computers� there is naturally no dwarf tossing coins� mainlybecause such a dwarf or any other known physical device would slowdown the computation considerably� not to mention of other technicalproblems� Randomness is simulated by complicated but non�random
��� Applications of linear algebra
computations� and doing this well is quite challenging� But in most pro�gramming languages there is a more or less satisfactory random numbergenerator at our disposal� so we will ignore this issue here and assumethat truly random numbers are available� The reader can �nd out muchmore about randomized algorithms� in particular more material relatedto Freivalds� checker� in the book by Motwani and Raghavan ����� Thisbook is delightful reading for anyone interested in combinatorics andtheoretical computer science�
In our case� if A�B�C are �xed matrices with AB � C� the al�gorithm in the theorem may sometimes answer INCORRECT andsometimes CORRECT� depending on the outcome of its random in�ternal decisions� The theorem claims that the �wrong answer COR�RECT has probability no more than �
� �But wait� the reader may cry� does this mean that if the multi�
plication done by MATRIX WIZARD is incorrect� the checker mayclaim the result correct with probability �
�� Come on� this is muchworse than the reliability of a weather forecast� Well� yes� but there�sa subtle di�erence� we can run the checking algorithm several timesfor the same matrices A�B�C� and a single answer INCORRECTsu�ces to detect that AB � C� If we make k runs for the sameA�B�C with AB � C� the probability that we get the wrong an�swer CORRECT every time� and thus fail to detect the error in
the multiplication� is only at most���
�kbecause the results of the
runs are independent� For instance� for k � ��� this probability isbelow ������ which is most likely much smaller than the chance ofthe computer running the matrix multiplication algorithm being de�stroyed by ants or nuclear war next Friday� �In contrast� listeningto �� weather forecasts in a row doesn�t seem to provide such anear�absolute certainty about tomorrow�s weather� So we can re�formulate the theorem�s conclusion as follows� with running timeO�n� log �
� � the probability of a wrong answer can be bounded by ��for any prescribed parameter � � ��
Proof of Theorem ������� The algorithm is actually very simple�We choose a random vector x � f�� �gn� all the �n possible vectorshaving the same probability �the underlying probability space is thusCn as in De�nition ������ We calculate the vector y � ABx � Cx�where x and y are considered as n � matrices� If y � � we outputCORRECT� otherwise we output INCORRECT�
���� Probabilistic checking ���
A vector can be multiplied by an n n matrix using O�n� op�erations� The right way of computing the product ABx is A�Bx�where we need two matrix�vector multiplications� Hence y can becomputed in O�n� steps� It remains to prove the claim about prob�ability� Obviously� if AB � C then y � ABx�Cx � �AB�Cx � ��hence in this case the algorithm always says CORRECT� So assumethat AB � C and write D � AB�C� It su�ces to prove the follow�ing�
Lemma� Let D be any rational n n matrix with at least one
nonzero entry� Then the probability of y � Dx being the zero vector�
for a random vector x � f�� �gn� is at most �� �
Proof of the lemma� Suppose that dij is a nonzero entry of D� Weshow that in such a case� yi � � holds with probability at most �
� �We have
yi � di�x� % di�x� % � � �% dinxn � dijxj % S�
whereS �
Xk���������n
k ��j
dikxk�
Imagine that we choose the values of the entries of x according tosuccessive coin tosses and that the toss deciding the value of xj ismade as the last one �since the tosses are independent it doesn�tmatter� Before this last toss� the quantity S is already �xed� be�cause it doesn�t depend on xj� After the last toss� we either leave Sunchanged �if xj � � or add the nonzero number dij to it �if xj � ��In at least one of these two cases� we must obtain a nonzero number�Consequently� the probability of yi � � is at most �
� � This proves thelemma and also concludes the proof of Theorem ������� �
It is very well known that writing an error�free software for a com�plicated task is almost impossible� This is quite alarming since we arebeing increasingly surrounded by computer�controlled devices� and thepossibility of their failure is very real well�known examples were serioussoftware�related problems in the Apollo or Space Shuttle projects� buttoday one really doesn�t have to go to outer space to encounter a soft�ware malfunction� The idea of using an independent checker to verifythe correctness of results obtained by complicated software is gainingin popularity� Research in theoretical computer science revealed thate�cient probabilistic checking is possible for almost any computation�In principle� the work of a very fast computer can be checked� with
��� Applications of linear algebra
a high reliability in the sense of probability� by a much slower com�puter� Although such results haven�t yet been put widely into practice�they certainly raise interesting possibilities� Moreover� the �program�checking� stream of ideas has been merged with ideas from some otherlines of research and has led to some of the deepest and most unex�pected results in theoretical computer science� These results prove the�hardness of approximation� for certain algorithmic problems� For ex�ample� it has been known for a long time that the problem of �ndingthe largest complete subgraph of a given graph is a problem in a certainclass of di�cult problems called �NP�complete problems�� The new re�sults say that if there were an e�cient algorithm for approximating thesize of the largest complete subgraph within any reasonable factor thenthere would also be an e�cient algorithm for �nding that size exactly�It seems somewhat mysterious that the proof of such a result should berelated to probabilistic program checking� but that�s the way it is� Theseresults are very new and there is no �classical� textbook treatment� Acomprehensive survey was written by Arora and Lund �����
Probabilistic associativity testing� Let S be a set and let �be some binary operation on S� This means that any two elementsa� b � S are assigned some element c � S� and this c is denotedby a � b� Formally� � is thus a mapping S S � S� You knowmany binary operations with numbers� For example� �%� �additionis a binary operation on the set of all natural numbers and ����subtraction is a binary operation on the set of all integers� On theother hand� ��� is not a binary operation on N and ��� �divisionis not a binary operation on the set of all real numbers in the senseof our de�nition� These everyday operations usually satisfy variouslaws� like commutativity �a%b � b%a or associativity ��a%b%c �a% �b% c� Here we will consider a quite arbitrary operation � thatmay be quite lawless and anarchistic� we assume no commutativity�no associativity� nothing like that�
In algebra� a set S with an arbitrary binary operation on it is calleda groupoid�It may be instructive to compare the de�nition of a binary operation
on S to the de�nition of a binary relation on S� a relation assigns toevery pair a� b � S�S a yes�no answer the elements are either relatedor not� while an operation assigns to a� b a �result� lying again in S�While nonmathematical examples of relations abound� it seems thatoperations in the considered sense are peculiar to mathematics� at leastwe can�t see any convincing and nontrivial nonmathematical examples�Of course� there are many situations when two objects give rise to athird object of the same kind� but for a binary operation we require
���� Probabilistic checking ���
that any two objects can be so combined and that the result is againfrom the same a priori chosen set of objects�
We will be interested in the case when S is a �nite set� and wesuppose that the operation � is speci�ed by a table� such as thefollowing for the case S � fA�B�/�'g�
� A B / '
A A A A AB A B / '/ A / A /' A ' A B
We would like to check whether the given operation � is asso�ciative or not� Call a triple �a� b� c � S� an associative triple if�a � b � c � a � �b � c holds� and a nonassociative triple otherwise�An obvious method is to go through all triples �a� b� c � S� and testwhether they are associative� For each triple �a� b� c� we need twolookups in the table to �nd �a � b � c and two more lookups to com�pute a � �b � c� Hence if jSj � n� the number of operations neededfor this straightforward associativity checking grows roughly as n��
We will present an ingenious algorithm for associativity testing�due to Rajagopalan and Schulman� which only needs O�n� oper�ations� It is again a randomized algorithm and it doesn�t give thecorrect answer with ���, certainty�
������ Theorem� There is a randomized algorithm with the fol�
lowing properties� It accepts as an input a binary operation � on ann�element set given by a table� The running time is O�n�� and the
algorithm outputs one of the answers ASSOCIATIVE or NONAS�
SOCIATIVE� In the case when � is associative� the algorithm always
declares it associative� and in the case when � is not associative� itdetects the nonassociativity with probability at least �
� �for any given
operation ���The probability of an incorrect answer can be made arbitrarily
small by repeating the algorithm enough times� similar to Theo�rem ������� That is� if we repeat the algorithm k times for a nonas�sociative operation it will give the answer NONASSOCIATIVE at
least once with probability at least �����
�k�
An obvious randomized algorithm for associativity testing wouldbe to repeatedly pick a random triple �a� b� c � S� and to test its as�sociativity� But the catch is that the nonassociativity need not man�
�� Applications of linear algebra
ifest itself on many triples� For example� the operation speci�ed inthe above table has only two nonassociative triples� namely �'�'�/and �'�/�'� while there are �� � �� triples altogether� In fact� forany n � � there is an example of an operation on an n�element setwith just one nonassociative triple �Exercise �� Hence� even if wetest n� random triples� the chance of detecting nonassociativity isonly �
n � and not a constant as for the algorithm in Theorem �������
Proof of Theorem ������� Let S be the given n�element set�First we de�ne a vector space over GF �� related to S� This will bevery similar to the de�nitions in Section ���� on the cycle space of agraph�
Let V denote the set of all n�tuples of �s and �s whose componentsare indexed by the elements of S� For a � S and v � V � we let �va �f�� �g denote the component of v corresponding to the element a�Moreover� for an element a � S� let va be the characteristic vectorof the set fag� that is� the vector with the component correspondingto a equal to � and with all other components ��
The set V can be regarded as a vector space over the ��element�eld GF ��� which is again similar to the considerations related tothe cycle space of a graph� Vectors are added and multiplied by anelement of GF �� componentwise�
Since we will be dealing with objects of several di�erent kinds� wewill distinguish them notationally as follows� letters u� v� w stand forelements of V � i�e� n�tuples of �s and �s� Greek letters � � � denoteelements of GF ��� i�e� � or �� and a� b� c� p� q� r are elements of S�
Next� based on the operation � on S� we de�ne a binary operation�denoted also by �� on V � For u� v � S� we set
u � v �Xa�b�S
�ua�vbva b�
On the right�hand side� the multiplication �ua�vb is in GF ��� theresult multiplies va b as a vector� and the sum is addition of vectorsin V � To make this more intuitive� suppose for a moment that S �fp� q� rg� and write u � pvp%qvq%rvr� v � pvp%qvq%rvr�Of course� p� q� r � f�� �g are just the components of u� andsimilarly for v� To �nd the vector u � v� we �rst �multiply out� theparentheses�
�pvp % qvq % rvr � �pvp % qvq % rvr
���� Probabilistic checking ���
� pp�vp � vp % pq�vp � vq % � � � % rr�vr � vr�Then this expression is �simpli�ed� using the de�nition va�vb � va bfor all a� b � S�
We claim that the operation � on V is associative if and only if� on S was associative� Clearly� if �a� b� c is a nonassociative triplein S� with �a � b � c � p � q � a � �b � c� we have �va � vb � vc �vp � vq � va � �vb � vc� Checking the associativity of � on V for anassociative � on S is an easy exercise �Exercise ��
For the associativity�checking algorithm� we de�ne a functiong�V � � V by setting
g�u� v� w � ��u � v � w�� �u � �v � w��By the above discussion� all values of g are � if and only if � isassociative �on V and also on S� Note that if vectors u� v � V aregiven� u � v can be calculated using O�n� operations using the tablespecifying � on S� Therefore g�u� v� w can be evaluated in O�n�time too�
Now we are ready to formulate the algorithm for Theorem �������
������ Algorithm� Select vectors u� v� w � V at random and inde�pendently of each other �each of the �n vectors of V has the sameprobability of being selected for u etc�� Compute g�u� v� w and an�swer ASSOCIATIVE if g�u� v� w � � and NONASSOCIATIVE oth�erwise�
It remains to prove that for a nonassociative operation �� the an�swer NONASSOCIATIVE is returned with probability at least �
� �This means that at least �
� of the possible triples �u� v� w � V � arenonassociative� To this end� �x some nonassociative triple �a� b� c �S�� Call two triples �u�� v�� w� and �u�� v�� w� equivalent if u� andu� agree in all components but possibly the component correspond�ing to a �i�e� u� � u� � va� � GF ��� v� and v� coincide ev�erywhere except possibly in the component of b� and w�� w� di�eronly possibly in the c component� Each class of this equivalence hasexactly � elements� We show that each class contains at least onenonassociative triple�
Lemma� Let �a� b� c be a �xed nonassociative triple� For all u� v�w � V � there exist � � � � GF �� such that
g�u % va� v % vb� w % �vc � ��
��� Applications of linear algebra
Proof of the lemma� We actually show that the sum
� �X
������GF ��
g�u % va� v % vb� w % �vc
is nonzero� By the de�nition of the operation � on V � we obtain� forany u� v� w � V �
g�u� v� w �X
p�q�r�S�up�vq�wrvg�p�q�r �
Substituting this into the sum � and exchanging the summationorder� we get
� �X
p�q�r�S
� X������GF ��
�u% vap�v % vbq�w % �vc
�vg�p�q�r �
The sum in the brackets can be rewritten� using distributivity inGF ��� as follows�X
������GF ��
�u% vap�v % vbq�w % �vc
� ��up % �u% vap� ��vq % �v % vbq� ��wr % �w % vcr�
� ��u% vap��v % vbq��w % vcr � �vap�vbq�vcr
because � � � % � � � in GF ��� Consequently� the only possiblynonzero term is obtained for p � a� q � b� and c � r� and so � �vg�a�b�c � �� This proves the lemma and also �nishes the proof ofTheorem ������� �
Remarks� The algorithm and its analysis could also be formulated with�out introducing the vector space V � We could just talk about randomsubsets of S etc�� but this seems to obscure the whole thing insteadof making it more accessible� The approach can also be generalized toverify other identities for one or several binary or k�ary operations on agiven �nite set� although interesting open problems remain� More detailscan be found in the original paper Rajagopalan and Schulman �����
Exercises
�� Suppose that we chose the components of the vector x randomly fromthe set f � �� � � � �mg instead of from f � �g in Freivalds� checker The�orem ������� Show that the probability of a wrong answer is at most�m in this case�
���� Probabilistic checking ���
�� �Suppose that we have a program for multiplying two polynomialspx� qx with integer coe�cients very quickly� Can you design amethod for a fast probabilistic checking of the correctness of the result�analogous to Freivalds� matrix multiplication checker� That is� giventhree polynomials px� qx� and rx� the algorithm should checkwhether rx � pxqx� Use the fact that a nonzero polynomial ofdegree d has at most d roots�
�� How many binary operations on an n�element S are there�
�� �For each n �� �nd an example of an n�element set S with a nonasso�ciative binary operation that possesses only one nonassociative triple�
�� Prove that if is an associative operation on S then also the operation on V de�ned in the proof of Theorem ������ is associative�
�� CS Implement the randomized algorithm for associativity testing� Com�pare its speed with the straightforward On� algorithm for variousinputs�
�� Let S be a �nite set with a binary operation � For a set G � S�de�ne G��� � G and G�k��� � G�k� � fa b� a� b � G�k�g� and puthGi � S�
k��G�k�� A set G � S is called a generator set if hGi � S�
a Show that if G is some generator set and a g c � a g cholds for any a� b � S and any g � G then must be associative�b �Call the operation cancellative if for every a� b � S� there existsa unique x � S with a x � b and a unique y � S with y a � b� Provethat if is cancellative� A � S is a nonempty set� and b � S n hAi thenjhA � fbgij �jhAij�c Using b� prove that if jSj � n and is cancellative then a gen�erator set of size at most log� n � � exists and
CS��it can be found inOn� logn time�
Hence� for a cancellative operation � a and c together give anassociativity testing algorithm with no randomness involved and withOn� logn running time�
�� Final exercise
a Having read the book� can you now give solutions to all the prob�lems raised in Section ����
b Explain a solution of at least one of them to an educated nonspe�cialist to one who has only learned some high�school mathematics�say� This exercise may be one of the most important ones in thisbook for the student�s future career�
��� Applications of linear algebra
Appendix� Prerequisites fromalgebra
This is a microcourse of matrices� vector spaces� �elds� and a fewother things from algebra that are used at some places in the book�Unlike other chapters� this part is not meant to be a textbook in�troduction to the subject� It is mainly intended for the reader whohas some knowledge of the subject but may have forgotten the exactde�nitions or may know them in a slightly di�erent form�
Matrices� A matrix is a rectangular table of numbers� The en�tries may be real numbers� complex numbers� or sometimes elementsof other algebraic structures� An m n matrix has m rows and ncolumns� If a matrix is called A� then its entry in the ith row andjth column is usually denoted by aij � So� for example� a �� matrixA has the general form�
B a�� a�� a�� a��a�� a�� a�� a��a�� a�� a�� a��
CA �
Note that a matrix is denoted by writing large parentheses to enclosethe table of elements�
A matrix is multiplied by a number by multiplying each en�try by � Two m n matrices A and B are added by adding thecorresponding entries� That is� if we denote C � A % B� we havecij � aij % bij for i � �� �� � � � �m and j � �� �� � � � � n�
Matrix multiplication is more complicated� A product AB� whereA and B are matrices� is de�ned only if the number of columns of Ais the same as the number of rows of B� If A is an mn matrix andB is an n p matrix� then the product C � AB is an m p matrixgiven by
cij � ai�b�j % ai�b�j % � � �% ainbnj �
Pictorially�
��� Appendix� Prerequisites from algebra
n
mn
p
row icolumnj� �
AB
C
cijm
p
If A is an m n matrix and x � �x�� x�� � � � � xn is a vector� wemay regard x as an n � matrix �so we think of the vector as beingwritten in a column and consider the product Ax as a product oftwo matrices�
If A is an mn matrix then AT denotes the nm matrix havingthe element aji in the ith row and jth column� The matrix AT iscalled the transposed matrix A� For example� if x � �x�� x�� � � � � xnis regarded as a column vector� i�e� as an n � matrix� then xT is a�nmatrix or a row vector� �In the literature� vectors are sometimesregarded as row vectors even without the transposition symbol� If xand y are n�component �column vectors� the product xT y is a � �matrix� i�e� a single number� called the scalar product of x and y�Explicitly� we have xT y �
Pni�� xiyi� The vectors x and y are called
orthogonal if xT y � ��For transposing the matrix product� we have the formula �ABT �
BTAT �Here is some more terminology for matrices� A square matrix is an
nnmatrix� i�e� one with the same number of rows and columns� Thediagonal �sometimes called the main diagonal of an nn matrix Aconsists of the elements a��� a��� a��� � � � � ann� see a schematic �gure�
An upper triangular matrix is one having �s everywhere below thediagonal� i�e� with aij � � whenever i � j� A diagonal matrix mayonly have nonzero entries on the diagonal� i�e� aij � � for i � j� Then n identity matrix In has �s on the diagonal and �s elsewhere�
Determinants� Every square matrixA is assigned a number det�Acalled the determinant of A� The determinant of A is de�ned by theformula
Appendix� Prerequisites from algebra ���
det�A �X��Sn
sgn��nYi��
ai���i �
where the sum is over all permutations � of the set f�� �� � � � � ng� andwhere sgn�� denotes the sign of a permutation �� The sign of anypermutation is either %� or ��� and it can be compactly de�ned asthe sign of the expressionY
��i�j�n���j� ��i�
For example� the determinant of a � � matrix A equals a��a�� �a��a��� This is also almost the only case when the determinant iscomputed from the de�nition� For larger matrices� the determinantis calculated by various other methods� Such methods are usuallybased on the rules for determinants listed below�
�� The determinant of an upper triangular matrix �in particular�of a diagonal matrix equals the product of the entries on thediagonal�
�� ��Elementary row operation I� If all entries in some row of amatrix A are multiplied by some number then the determinantis multiplied by � In particular� if A has a row of all zeros thendet�A � �� Similarly for a column�
�� ��Elementary row operation II� The determinant is not changedby adding a multiple of one row to another row� That is� if i � kare row indices and if the entry aij is replaced by aij % akj forj � �� �� � � � � n� where is a �xed number� then the determinantremains the same� Similarly for columns�
�� If A�B are n n matrices then det�AB � det�A det�B�
�� ��Expanding the determinant according to a row� For any rowindex i� we have the formula
det�A �nX
j��
���ij det�Aij�
where Aij denotes the matrix arising from A by deleting the ithrow and the jth column�
A square matrix A is called regular if det�A � �� A submatrix ofa matrix A is any matrix that can be obtained from A by deletingsome rows and)or columns of A� The rank of an n m matrix A�
��� Appendix� Prerequisites from algebra
denoted by r�A� is the maximum number k such that a regular kksubmatrix of the matrix A exists �below� an alternative de�nition ofrank will be given� For the product and sum of matrices� we have theinequalities r�AB � max�r�A� r�B and r�A%B � r�A % r�B�
Groups and �elds� Let X be a set� A binary operation on X isa mapping of X X into X� that is� any two elements a� b � X areassigned some element of X �see also Section ����� For example�addition and multiplication are binary operations on the set of allnatural numbers �while subtraction is not� Binary operations areusually written using symbols like �� �� %� �� etc�� so for example if� is a binary operation� we write a � b for the element assigned by �to the pair �a� b�
A binary operation � is called associative if we have a � �b � c ��a � b � c for all a� b� c � X� A binary operation � is commutativeif a � b � b � a for all a� b � X� Practically all binary operationsone encounters in everyday mathematics are associative� but thereare common and important operations that are not commutative�such as the multiplication of n n matrices or the composition ofmappings on some set�
A group is a set G with an associative binary operation � satisfy�ing the following axioms �there are many equivalent versions of theaxioms�
�i There exists an element e � G� called the unit element or theneutral element� such that a � e � e � a � a holds for all a � G�
�ii For every a � G� there exists an element b � G with a � b �b � a � e� where e is the unit element� Such a b is called theinverse of a and it is usually denoted by a���Some important examples of groups are the integers with the op�
eration of addition� the set of all positive reals with the operation ofmultiplication� the set of all regular n n real matrices with mul�tiplication� the set of all permutations on a given set X with theoperation of composition� and the set of all rotations around theorigin in the ��dimensional space with the operation of composition�performing one rotation and then another� On the other hand� thenatural numbers with addition or the real numbers with multiplica�tion do not form a group�
A eld is a set K with two binary operations % and � �here thesesymbols need not denote the usual operations with numbers� suchthat the following hold�
Appendix� Prerequisites from algebra ���
�� The set K with the operation % is a commutative group withthe unit element denoted by ��
�� The set K n f�g with the operation � is a commutative groupwith the unit element denoted by ��
�� Distributivity holds� a � �b%c � �a �b%�a �c for any a� b� c � K�
The multiplication a � b is often written just ab� The most important�elds are the rational numbers� the real numbers� and the complexnumbers �with addition and multiplication as operations� On theother hand� the integers with addition and multiplication do notform a �eld�
If K is a �eld and L is a subset of K that contains � and � of K�is closed under both the operations of K �i�e a% b � L and a � b � Lholds for any a� b � L� and is a �eld with these operations then Lis called a subeld of K� For example� the �eld of the rationals is asub�eld of the reals�
In combinatorics� we are often interested in �nite �elds� A �nite�eld with q elements� if one exists� is commonly denoted by GF �q�The simplest �nite �eld is GF ��� which is just the set f�� �g with theusual multiplication of integers and with addition given by � % � �� % � � �� � % � � � % � � �� A �nite �eld GF �q is known to existif and only if q is a power of a prime number� If q is a prime� GF �qcan be easily described� it is the set f�� �� �� � � � � q � �g� where theaddition and multiplication are performed as for integers� but afteradding or multiplying two numbers we take the remainder of theresult after dividing it by q �we say that we do arithmetic modulo q�The above de�nition of GF �� is a special case of this construction�On the other hand� if q � pk for a prime p and k � �� then theset f�� �� � � � � q � �g with arithmetic modulo q is not a �eld� and theconstruction of GF �q is di�erent and more complicated�
Vector spaces� Let K be a �eld �most of the time one can thinkof the real numbers� A vector space over K is a commutative groupV with an operation % and neutral element � plus a mapping �op�eration assigning to every pair �� v with � K and v � V anelement of V � That is� any element of V can be �multiplied� by anyelement of K� This multiplication is usually written without anymultiplication sign� so we write just v for v multiplied by � Werequire the following conditions� for any u� v � V and any � � K��u % v � u % v� � % v � v % v �these are two kinds ofdistributivity� �v � �v �a kind of associativity� and �v � v�
�� Appendix� Prerequisites from algebra
From this one can prove various other properties� such as �v � ��the left � is in the �eld K and the right � in the vector space V �The elements of V are called vectors�
The most usual and most important example of a vector spaceis one consisting of all n�tuples of real numbers �for some given in�teger n� with componentwise addition and multiplication by a realnumber� This is a vector space over the �eld of real numbers� butsimilarly one can consider the vector space of all n�tuples of elementsof some �eldK� which gives a vector space over K� This vector spaceis usually denoted by Kn�
A set A � V is called linearly dependent if there exist elementsv�� v�� � � � � vn � V � n � �� and nonzero �� �� � � � � n � K with�v� % �v� % � � � % nvn � �� If A is not linearly dependent it iscalled linearly independent�
The maximum possible cardinality of a linearly independent setin V is called the dimension of V � and any linearly independent setin V of that cardinality is called a basis of V � The vector space Kn
has� as everyone would expect� dimension n�Every vector space has a basis� and every inclusion maximal lin�
early independent set is a basis� In combinatorics� we almost alwaysdeal with vector spaces of a �nite dimension� If �e�� e�� � � � � en is a ba�sis of an n�dimensional vector space V � then any vector v � V can beuniquely represented as v �
Pni�� iei for some �� �� � � � � n � K�
Here �� � � � � n are called the coordinates of v with respect to thebasis �e�� � � � � en� Every vector v � V is thus assigned a vector fromKn� namely the n�tuple of its coordinates� In this way� V is putinto a bijective correspondence with the vector space Kn �there aremany such correspondences� depending on the particular choice ofa basis� All n�dimensional vector spaces over a given �eld are �thesame�� i�e� they are all isomorphic in a suitably de�ned sense� HenceKn can be viewed as the n�dimensional vector space over K� andvectors can usually be thought of as n�tuples of numbers� On theother hand� sometimes it is convenient to work with other versionsof n�dimensional vector spaces over K as well�
A subspace of a vector space V is a subset W � V that is closedon addition and on multiplication by elements of K� i�e� such thatu%v �W and u �W holds for any � K and u� v �W � If X � Vis a set of vectors� then the subspace generated by X or the linear
span of X is the smallest subspace of V containing X� Explicitly� it
Appendix� Prerequisites from algebra ���
is the set fPni�� ivi� n � N� �� � � � � n � K� v�� � � � � vn � Xg�
The rank of an m n matrix A� with entries from a �eld K�equals the dimension of the subspace generated by the rows of A�considered as n�element vectors in the space Kn� It also equals thedimension of the subspace generated by the column vectors of A inKm� In fact� this de�nition of rank can be regarded as a �more basic�one than the de�nition via determinants given above�
If V and W are vector spaces over a �eld K� we de�ne a linear
mapping of V into W as a mapping f �V � W satisfying f�u �f�u and f�u% v � f�u % f�v for any � K and u� v � V � Thekernel of f is the set ker�f � fv � V � f�v � �g� The kernel of f isa subspace of V and the set f�V is a subspace of W � The dimensionof f�V is called the rank of f � For any linear mapping f �V � W�we have dimker�f % dimf�V � dimV �
Let �e�� e�� � � � � en be a basis of V and �f�� f�� � � � � fm a basis ofW � Then linear mappings f �V � W are in a bijective correspon�dence with the mn matrices with entries from K� As we know� anyvector v � V is uniquely written v �
Pni�� iei� Any linear mapping
f �V �W can be expressed as follows�
f�v � f
� nXi��
ivi
��
mXj��
� nXi��
ajii
�fj�
where aij are the elements of the mn matrix A corresponding to f �In other words� if is the column vector of coordinates of v withrespect to the basis �e�� � � � � en and denotes the column vector ofcoordinates of f�v with respect to the basis �f�� � � � � fm then wehave � A�
Thus� linear mappings can be regarded as abstract versions ofmatrices� Multiplication of matrices corresponds to composition oflinear mappings� The rank of a linear mapping coincides with therank of its matrix �with respect to any choice of bases�
In conclusion� let us remark that many notions of linear alge�bra have nice geometric interpretations in the usual Euclidean spacewhich may be helpful for understanding both geometry and lin�ear algebra� Especially for applications in discrete mathematics� oneshould learn linear algebra together with these geometric connec�tions�
��� Appendix� Prerequisites from algebra
Bibliography
Basic textbooks
��� N� Biggs� Discrete Mathematics� Revised edition� ClarendonPress� Oxford� �����
��� B� Bollob�as� Graph Theory� An Introductory Course� corrected�rd printing� Graduate Texts in Mathematics ��� Springer�Verlag� Berlin etc�� �����
��� P� Cameron� Combinatorics Topics� Techniques� Algorithms�Cambridge University Press� Cambridge� �����
��� R� Diestel� Graph Theory� Graduate Texts in Mathematics ����Springer�Verlag� Berlin etc�� �����
��� R� Graham� D� Knuth� and O� Patashnik� Concrete Mathe�matics A Foundation for Computer Science� Addison�Wesley�Reading� Massachusetts� �����
��� J� H� van Lint and R� M� Wilson� A Course in Combinatorics�Cambridge University Press� Cambridge� �����
��� L� Lov�asz� Combinatorial Problems and Exercises� �nd edition�Akad�emiai Kiad�o� Budapest� and North�Holland� Amsterdam������
��� I� Stewart and D� Tall� The Foundations of Mathematics� OxfordUniversity Press� Oxford� �����
Further reading on related topics
��� A� Aho� J� Hopcroft� and J� Ullman� The Design and Anal�
ysis of Computer Algorithms� Addison�Wesley� Reading� Mas�sachusetts� �����
���� N� Alon and J� Spencer� The Probabilistic Method� John Wiley�New York� �����
���� S� Arora and C� Lund� Hardness of Approximation� in Ap�
proximation Algorithms for NP�hard Problems� edited byD� Hochbaum� PWS Publishing� Florence� Kentucky� �����
��� Bibliography
���� L� Babai and P� Frankl� Linear algebra methods in combinatorics
�Preliminary version �� Department of Computer Science� TheUniversity of Chicago� �����
���� E� R� Berlekamp� J� H� Conway� and R� K� Guy� Winning Ways
for Your Mathematical Plays� Vol� �� Games in general� Vol� ��Games in particular� Academic Press� London� �����
���� N� Biggs� Algebraic Graph Theory� �nd edition� Cambridge Uni�versity Press� Cambridge� �����
���� J� M� Borwein and P� B� Borwein� Pi and the AGM� John Wiley�New York� �����
���� G� Bredon� Topology and Geometry� Graduate Texts in Mathe�matics ���� Springer�Verlag� Berlin etc�� �����
���� D� Cox� J� Little� and D� O�Shea� Ideals� Varieties� and Algo�
rithms� An Introduction to Computational Algebraic Geometry
and Commutative Algebra� �nd edition� Springer�Verlag� Berlinetc�� �����
���� G� R� Grimmett and D� R� Stirzaker� Probability and Random
Processes� �nd edition� Oxford University Press� Oxford� �����
���� F� Harary and E� M� Palmer� Graphical Enumeration� AcademicPress� New York and London� �����
���� N� Koblitz� A Course in Number Theory and Cryptography� �ndedition� Graduate Texts in Mathematics ���� Springer�Verlag�Berlin etc�� �����
���� J� Littlewood� A Mathematician�s Miscellany� London� Methu�en� �����
���� B� Mohar and C� Thomassen� Graphs on Surfaces� Johns Hop�kins University Press� Baltimore� Maryland� �����
���� R� Motwani and P� Raghavan� Randomized Algorithms� Cam�bridge University Press� New York� �����
���� J� G� Oxley� Matroid Theory� Oxford University Press� Oxford������
���� J� Pach and P� K� Agarwal� Combinatorial Geometry� John Wi�ley� New York� �����
���� A� de Saint�Exup�ery� Le petit prince� English translation The
Little Prince� Harcourt Brace� San Diego� California� �����
���� J� Stillwell� Classical Topology and Combinatorial Group The�
ory� Graduate Texts in Mathematics ��� Springer�Verlag� Berlinetc�� �����
Bibliography ���
���� W� T� Trotter� Combinatorics and Partially Ordered Sets Di�
mension Theory� Johns Hopkins Series in the Mathematical Sci�ences� Johns Hopkins University Press� Baltimore� Maryland������
���� G� Ziegler� Lectures on Polytopes� Graduate Texts in Mathemat�ics ���� Springer�Verlag� Berlin etc�� �����
Other references���� G� E� Andrews� The Theory of Partitions �Encyclopedia of
mathematics and its applications� vol� �� Addison�Wesley�Reading� Massachusetts� �����
���� D� Bayer and P� Diaconis� Trailing the dovetail shu.e to its lair�Annals of Applied Probability ������� No� �� ��������
���� Th� Beth� D� Jungnickel� and H� Lenz� Design Theory� B�I� Wis�senschaft Verlag� Mannheim� Wien� Z"urich� �����
���� K� Chandrasekhar� Introduction to Analytic Number Theory�Springer�Verlag� Berlin etc�� �����
���� P� Flajolet� B� Salvy� and P� Zimmerman� Automatic average�case analysis of algorithms� Theoretical Computer Science
������� �������
���� R� L� Graham� M� Gr"otschel� and L� Lov�asz �editors� Handbookof Combinatorics� Vol� ���� North�Holland� Amsterdam� �����
���� G� Kant� Drawing planar graphs using the canonical ordering�Algorithmica ������� �����
���� D� Karger� P� Klein� and R� Tarjan� A randomized linear�timealgorithm to �nd minimum spanning trees� Journal of the ACM������� ��������
���� D� Knuth� The Art of Computer Programming� Vol� I� Funda�mental Algorithms� Addison�Wesley� Reading� Massachusetts������
���� S� Rajagopalan and L� J� Schulman� Verifying identities �ex�tended abstract� Proc� ��th Annual IEEE Symposium on Foun�
dations of Computer Science� pages �������� IEEE� Los Alami�tos� California� �����
���� N� Robertson� D� P� Sanders� P� D� Seymour� and R� Thomas�The Four Color Theorem� Journal of Combinatorial Theory Ser�B �������� �����
���� N� Robertson� P� D� Seymour� and R� Thomas� Permanents�Pfa�an orientations� and even directed circuits� preprint� Geor�
��� Bibliography
gia Institute of Technology� Atlanta� ���� �available electroni�cally at www�math�gatech�edu��thomas�
���� M� Sharir and P� K� Agarwal� Davenport�Schinzel Sequencesand Their Geometric Applications� Cambridge University Press�Cambridge� �����
���� I� Stewart� Mathematical recreations� Scientic American
��������� No� �� ������
���� C� Thomassen� The Jordan�Schoen ies theorem and the classi��cation of surfaces� American Mathematical Monthly ��������No� �� ��������
Hints to selected exercises
������ Denote the right�hand side by m� Hence m is the unique integersatisfyingm� � bxc � m���� This holds if and only ifm� � x � m����and hence m � bpxc������d� See Section � ��� Exercise ��
������ Write each number in the form �k�m��� k�m integers� Sincem can attain at most � distinct values� the considered set contains twonumbers of the form �k�m� � and �k
�
�m� �� k � k��
�����a� Adding the next line to n lines already present slices exactly n��of the existing regions into two�
�����b� Use a in an induction step� The result is n� � �n� ����
������ Prove that the numerator decreases in each step�
������ Cut the chessboard into four �n�� � �n�� parts� Place one L�shapeso that it has one square in each part� except for the one with a missingsquare�
�����b� The strategy is to invert the previous moves of the �rst player�In proving that it works� proceed by contradiction if there was a repetitioncaused by the second player� �nd an earlier repetition caused by the �rstplayer�
���� � Induction on n� Let R be the lowest row initially containing a blacksquare� and let C be the leftmost such column� By the inductive hypothesis�after moment n� � all squares above R are white� and also all squares tothe right of C� The only possible remaining black square at the intersectionof R and C disappears at the moment n�
������ �� By induction on m� describe the distribution of particles at time�m � ��������� De�ne x� � minM� xi�� � minM n fx�� � � � � xig� Should M bein�nite� the set fx�� x�� � � �g would have no largest element�������� For instance� �rst show that if � � ni � nj � then the sum of squaresdoesn�t decrease by replacing ni by ni�� and nj by nj��� Then prove thatby repeating this operation� any initial values of the ni can be convertedto the situation described in the incomplete solution�
������� One possibility is by induction on n� Suppose the claim holds forall n � n�� and consider some M for n � n�� Set M
� � M n f��� n�g� If nointerval of M � contains � then jM �j � n � � by the inductive hypothesis�
��� Hints to selected exercises
Otherwise let q � n� be largest with ��� q� � M �� let M� � fI � M �� I ���� q�g� and M� �M � nM�� Use the inductive hypothesis for M� and M��
������� kbn��c� To prove m � kbn��c� use the fact that each Ij containsat least one even number�
�����c� It su�ces to prove that there is no bijection from the setf�� �� � � � � ng onto a proper subset A � f�� �� � � � � ng� Proceed by induc�tion on n� The case n � � is clear� Suppose there were such a bijectionf � f�� �� � � � � ng � A� n � �� If fn � n or n �� A then f restricted tof�� �� � � � � n� �g gives a bijection of f�� �� � � � � n� �g to its proper subset�If fn � i �� n and fj � n for some j � n then de�ne gj � i�gk � fk for k �� j� n� This g is again a bijection of f�� �� � � � � n� �g onits proper subset�
�����a� There are only �nitely many relations on X �
�����c� Take N� ��
�����b� The pairs related by R S correspond to the nonzero entries ofthe matrix ARAS �
�����b� If the considered congruence � is not the diagonal� let q �minfjx� yj� x �� y� x � yg� Prove that �q coincides with �������c� Yes in a� no in b make all even numbers equivalent� whileeach odd number is only equivalent to itself�
������ De�ne a relation S � fx� x� x � Xg �R �R R �R R R � � � ��prove that this is an ordering�
������ For instance� the relation of immediate predecessor is empty for theset of all rational numbers with the usual ordering�
���� � By induction on jX j� Remove some minimal element of X and placeit as the �rst element in the linear ordering by �������b� A �nite linearly ordered set has a unique largest element� Mapit to the largest element of the other set� and proceed by induction�
�����c� The natural ordering� and the opposite ordering � $ � $ � $� � ��
�����d� Uncountably many� partition N into in�nite subsets S�� S�� � � ��place S� after S�� S� after S�� � � � � each Si is ordered either as the naturalordering of N or as its reverse�
������� Choose A � X � and to every x � X assign the set Mx � fy �X � y � xg�������d� Show that for any A � X � we have inf A � supfx � X � x �a for all a � Ag������� Encode a pair A�B by a mapping f � f�� �� � � � � ng � f � �� �g� anelement x � A receives value �� x � B nA value �� and x �� B value �
�����b� Choose the �rst column as any nonzero vector over the q�element�eld� The second column must not be a multiple of the �rst� which excludes
Hints to selected exercises ���
q vectors� The third column must not be a linear combination of the �rst� columns� and this excludes q� possibilities no two distinct linear com�binations of the �rst � columns give the same vector�check�� In general�there are qn � qi possibilities for the ith column�
������ Pair up each divisor d with n�d� If n is not a perfect square thenthis partitions all divisors into disjoint pairs�
������ n� ��������b� What is the order of a permutation with a single cycle oflength k� What if there are two cycles of length k� and k��
�����a� Show that if a permutation with k increasing segments is writtenbackwards� we get a permutation with n� �� k increasing segments�
�����b� Consider a permutation of the set f�� �� � � � � n� �g with k seg�ments in a one�line notation� and insert the number n into it on someof the possible n � � positions� For how many positions will the resultingpermutation have k � � segments� and for how many k segments�
�����c� A general formula� derived by Euler� is fn� k �Pk
j����j �k � jn
�n��j
��
�����d� Divide the permutations into classes according to the set of num�bers occurring on the �rst k � � positions� All orderings of the �rst k � �numbers have the same probability� For how many of the k � �� possibleorderings of the �rst k�� numbers do we get an initial increasing segmentof length exactly k� The resulting probability is k�k � ���
�����c� If the numbers are initially ordered according to a permutation ��then exchanging two neighbors removes at most � inversion of the currentpermutation�
�����b� How many among the numbers �� �� � � � � n are divisible by pj � forj � �� �� � � �� The resulting formula is bn�pc� bn�p�c� bn�p�c� � � �������b� The right�hand side is the number of r���tuples of nonnegativeintegers satisfying the equation X��X�� � � ��Xr�� � n� r� Divide theser���tuples into n�r groups according to the value of Xr��� and calculatethe number of solutions in each group separately� This yields the left�handside�
������ Transform the kth term into�nm
��n�mn�k
�and take
�nm
�in front of the
sum� The result is�nm
��n�m�
�����a� Use �k
�km
�� �
m
�k��m��
�and formula ����
�����b� This time k�km
�� k � �
�km
�� �km
�� m� �
�k��m��
�� �km
��
������ Let M be an m�element set and N an n�element set� Both sidescount the number of ordered pairs X�Y with X � M � Y � N �X � andjY j � m� For the left�hand side� we �rst select X and then Y � and for theright�hand side� we �rst pick Y �N � then Y �M � and �nally X �
�� Hints to selected exercises
������ Set ki � fi � � � fi� k� � f�� kn � n � fn� The desirednumber is the number of nonnegative integer solutions to the equationk� � k� � � � �� kn � n�
������ Consider such a subset fa�� � � � � akg� a� � a� � � � � � ak� Assignthe k�tuple fa�� a� � �� a� � �� � � � � ak � k � �g to it� This given a bijectionbetween all subsets of the required kind and
�f��������n�k��gk
��
������b� The result is�n���
���
������c� Calculate the area of the big square in two ways� Its side is�� � �� �� � � �� n� The k�th �layer� counted from the center consistsof �k squares of size k � k�
������b� In the formula ��� for the binomial coe�cient� exactly one ofthe factors in the numerator is divisible by p� So
�np
�is divisible by p if and
only if this factor is divisible by p� too�
������a� Substitute the following values into the binomial theorem�x � �� x � ��� x � i� and x � �i i � p�� stands for the imaginaryunit� Add the resulting equations together� Rewrite the nth powers on theright�hand side using de Moivre�s formula� The required number is givenby the remarkable expression �n�� � �n���� cos �n� � Verify its correctnessfor small values of n�
������b� Proceed as in a but substitute the � complex roots of theequation x� � � for x�
������� First arrange the elves� which determines � possible positions forthe goblins� pick � of these positions� and �nally arrange the goblins�
������� Those with A� as a vertex��n�k��k��
�� All� this number times n
k �
������b� Show that there are always precisely � triangles sharing � sideswith the n�gon� Starting from a triangle T� sharing � sides with the n�gon� we can pick a triangle T� neighboring T�� then T� neighboring T��etc� For T�� we have n possibilities� and in each subsequent steps there are� possibilities� Each of the considered triangulations is obtained twice bythis process� since there are � choices for the T� to start with� The resultis n�n���
������a� The left�hand side is the number of distinct orderings of nobjects� with ki objects of the ith kind� The right�hand side� �rst we choosethe kind of object at the �rst position and then we arrange the remainingobjects�
������a��r��r������rkr��r������rk
��
������b� n� ���Qki��ri � �� where n � jX j � � �
Pki��ri � ��
������ For example� fn � nbn��c� gn � nb�n�����c�����
������ jf j is bounded by a constant� jgj is bounded from below by a positiveconstant� jhj is bounded by some polynomial function������� First� rewrite all the functions in the form ef�n��
Hints to selected exercises ���
�����b� Write � � �n �
n��n � ���� �
n�� ��e����n����
������ The line y � x � � is a tangent to the graph of the function ex atthe point � �� The function ex is convex� since its second derivative isnonnegative� and so it cannot intersect its tangent anywhere else than atthe point of tangency�
�����b� Put A � x� � x� � � � � � xn���n � �� By AGn appliedto numbers x�� � � � � xn��� and A� we have A
n � x� � x� � � � � � xn�� �A�nn x�x� � � � xn��A� and from this we get A x� � � � xn��
���n����
������� The function lnx is concave� and so each triangle with verticesat points i� ln i� i � �� ln i� and i � �� lni � � lies completely belowits graph draw a picture� The area of this triangle is �
� lni � � � ln i�Hence lnn� � lnn�R n
�lnx dx� �
�
Pn��i�� lni��� ln i� A further formula
manipulation leads to the required result�
������� Induction on n�
������� Lower bound� by induction� prove �pn� � � pn � ��
pn by
transforming the left�hand side to a fraction with denominatorpn� � �p
n� Upper bound� similarly�
�����a� All such primes divide��mm
��
�����b� If P denotes the product of primes as in a� we have log� P ��m� and on the other hand� P m���m����m�� This gives ��m � �m�Om� lnm�
�����c� The largest power of p dividing n� has exponent bn�pc�bn�p�c�� � �� Use the equation ��mm �
� �m��m�� and express the di�erence of themaximum powers of p in the numerator and in the denominator�
�����d� By c� we have ��n�n� � � ��nn
� � �n���n�������� For instance� one can proceed as in the second proof of the inclusion$exclusion principle� i�e� consider the contribution of a single element�
�� ��b� Choose the points that are �xed� The rest is a permutationwithout a �xed point as in the hatcheck lady problem�
�� ��� Partition all permutations into classes depending on the number of�xed points� Express the number of permutations in each class using thefunction Dk�
�� ��a� Consider a distribution of hats to n gentlemen without �xedpoints� Gentleman No� � exchanges the hat he received for his hat withsome gentleman No� i and leaves� If gentleman No� i received his own hatin this exchange� he leaves too and we have a situation with n�� gentlemen�Otherwise we are left with n� � gentlemen��� ��c� Let the mapping go onto the set f�� �� � � � �mg� Let Ai be the setof mappings that do not map anything to the element i� Use inclusion$exclusion to determine jA� � � � � � Anj� i�e� the number of bad mappings�For m � n we must get n��
��� Hints to selected exercises
�� ��d� An onto mapping f �N �M � where jM j � m� de�nes an equiva�lence relation on N with m equivalence classes� Show that each equivalencewith m classes on N corresponds to exactly m� mappings onto�
�� � a� You can use the hint to d of the preceding exercise and theresult of c in that exercise�
�� � b� We sum the result of a over all k� We obtain the following
result�Pn
k���k
Pkj����j
�kj
�k � jn�
�� � c� In the result of b� write i for k � j� let k formally run to �this is possible since the inner sum� expressing the number of equivalenceswith k classes on an n�element set� is for k � n� and change the orderof summation�
�� ��� A number q is relatively prime to m if and only if its remainderafter division by n is relatively prime to m� Prove that for any pair a� b� � a � n� � b � m� there exists exactly one q � mn giving the remaindera after division by n and remainder b after division by m�
�� ���b� Rewrite each term in the product as � � pi � p�i � � � �� p�ii �
�� ���c� Let n � �qQr
i�� p�ii � pi odd primes� By b� we must have
�n � tQp�ii � p�i��
i � � � � � �� t � �q�� � �� After dividing this by theexpression t
Qp�ii we have ����t �
Q����pi� � � ����p�ii � At the same
time� some pi divides t� In order that the right�hand side is not larger thanthe left�hand side� we must have r � �� t � p��
�� ���� For every prime pi � N � let Ai be the set of pairs m�n suchthat pijn and pijm� Use inclusion$exclusion to determine the number ofbad pairs�
�� ���a� De�ne Ai as the set of all graphs in which the vertex i hasdegree � and calculate jA� � � � � � Anj��� ���� De�ne Ai as the set of all ways of seating in which the ith coupleis adjacent�
�����b� A simple counterexample arises as follows� take triangles withvertex sets f�� �� �g and f�� �� �g� and add the edges f�� �g� f�� �g� andf�� �g������� �n� ��n� ��n� � � � � � � � � �������� Here is a way of constructing �n
����O�n logn� nonisomorphic graphsthis is almost as many as we got by the counting argument in the text�Let n be large enough� and let m be the smallest integer with �m n�Denote the n vertices by a� b� c� d� u�� u�� � � � � um��� and v�� v�� � � � � vn�m���write U � fu�� � � � � um��g� V � fv�� � � � � vn�m��g� Connect a to b� and bto c� to d� and to all vertices of U � Choose some asymmetric graph on U �say the path u�� u�� � � � � um�� plus the edge fu�� u�g� Connect the verticesc and d to every vertex of V so a is the only vertex of degree �� Choose anarbitrary graph on V � Finally� connect each vertex vi � V to the verticesuj� � � � � � ujk � where � u� � u� � � � � � uk � m � � are the uniquely
Hints to selected exercises ���
determined numbers with �j� � �j� � � � � � �jk � i this corresponds towriting i in binary� It is easy to check that for distinct graphs on V we
obtain nonisomorphic graphs on n vertices� Hence we have at least �n�m��
�
nonisomorphic graphs on n vertices�
������ The most edges are clearly obtained if the components are completegraphs� If their numbers of vertices are n�� � � � � nk�
Pni � k� we have�
n��
��� � ���nk� � edges and we need to maximize this expression as a function
of n�� � � � � nk� Show that if� for example� n� n� � �� the value doesn�tdecrease by increasing n� by � and decreasing n� by �� Hence the maximumis attained for n� � n� k � � and ni � � for i � �� �� � � � � n�
������ If there is no odd cycle� assume that the graph is connected� andlabel the vertices by �� and�� by the following process� label an arbitrarilychosen vertex by ��� and whenever v is a vertex adjacent to a vertex labeledx label v by �x� Show that the whole graph gets labeled in this way andno two vertices with the same label are adjacent�
������ If v is a vertex with at least � neighbors it has to be connected toall vertices of its component� Each component has to be K� or K��n�
������ One component� any connected graph on � � vertices� a star K��n�a star K��n with one extra edge forming a triangle� two stars K��n andK��m whose centers are connected by an edge� By the center of a star wemean the vertex connected to all others�
���� � Graph diameter is usually de�ned as maxfdGu� v� u� v � V Gg�and radius as minvV �G� maxuV �G� dGu� v�
������� For a given vertex vi� the entry at position i� i in A�G is the number
of walks of length � starting and ending in vi� Each ��cycle in G appears�� as such a walk� But such a walk may also pass the same edge �� andeach edge is counted twice for such walks� or pass � edges with a commonvertex �� and each pair of edges with a common vertex appears ��������� For instance� the �rst graph has no cycle of length �� the second one� such cycles� and the third one � of them�
���� a� Never� Its score would have to be � �� � � � � n� �� but if there isa vertex adjacent to all other vertices no vertex may have degree �
���� b� For all n �� By induction� we construct graphs Gn withscore containing the numbers � �� � � � � n � �� with bn� ���c repeated�G� are � isolated vertices� Gn�� arises by adding an isolated vertex to thecomplement of Gn the complement of a graph G � V�E is the graphV�
�V�
� nE�������� Consider the coloring with the smallest possible number ofmonochromatic edges� If there were a monochromatic path of length ��one could switch the color of its middle vertex�
������� Consider a path in G of maximum possible length� Its end�vertexis connected to at least � other vertices of this path� this gives the desiredsubgraph�
��� Hints to selected exercises
�������We must have k � n��� and knmust be odd� This is also su�cient�for instance� set V � f � � � � � n� �g�E � ffi� jg� i� jmod n � Sg� whereS � f����� ����� � � � � k� ��k
�g for k even� S � f����� � � � � k��� ��k��
� � n� g fork odd� n even�
������� It su�ces to show that if fu� vg � EG then degGu � degGv�Let U be the set of all neighbors of u except for v� and let V be the setof all neighbors of v except for u� Each vertex in U has � neighbors in V �and similarly each vertex of V has � neighbors in U � Hence jU j � jV j bydouble�counting the edges among U and V �
������� By contradiction� Suppose that any two vertices have an odd num�ber of common neighbors� For an arbitrary vertex v� look at the subgraphinduced by the neighbors of v� All degrees in this subgraph are odd� andhence the degree of v is even� Let us count walks of length � beginning atv� Their total number is even because every vertex has an even degree�At the same time� an odd number of these walks come back to v� but anyother vertex is reached by an odd number of walks� and hence the numberof vertices distinct from v must be even�a contradiction�
�����a� For a �xed vertex set� proceed by induction by the number ofedges of G� Show that if EG �� � G contains a cycle� remove it������� The number of odd terms in the sequence is even�
������a� Consider the longest path in G and the sets of neighbors of itsend�vertices�
������b� In general� no consider a suitable complete bipartite graph�
������ Remove every knight with an ally sitting to his right� The remainingknights are from alternate castles as we go around the table� so their numberis even� and the number of removed knights is the same�
���� � By induction on the number of vertices� For an arbitrary vertex v�let T� be the tournament induced by the vertices with arrows going to vand T� the tournament induced by the vertices with arrows going from v�Take a path in T�� continue to v� and then by a path in T��
������ Induction on the number of vertices n� In a tournament T on nvertices� delete a vertex u� and let v be a vertex as required in the problemfor the remaining tournament� If v cannot be reached from u by a length �directed path in T then v� u � ET and also all vertices with an arrowgoing to v have an arrow to u� and hence u can be reached by at most �arrows from everywhere�
�����b� In Kn��� subdivide each edge�
�����c� Let T be a tree see Chapter � in which all vertices except forleaves have degree n� and having a vertex at distance n from all leavesa complete n�ary tree� Make a copy T � of T � and identify each leaf of T �
with its pre�image in T �
�����a� Yes�
Hints to selected exercises ���
�����b� Yes�
������ For instance� by induction� using a synthesis of the graph by suc�cessive �gluing of ears��
������ It is k� Prove that any two vertices of the cube can be connected byk vertex�disjoint paths�
������ Let A be a set of k vertices� Double�count the edges connecting Ato the other vertices� assuming that G�A has more than k components�
������ For n � �k� �� G must be a K�k��� For n �k� if there is a vertexof degree � �k� �� delete it and use induction� Otherwise� suppose that Gminus some � k�� vertices can be partitioned into two nonempty parts G�
and G� with no edges connecting them� Show that the inductive hypothesisholds for G� or for G�� for otherwise G would have too few edges�
������ We have �n � � � �jET j � PvV �T � degT v �
Pn��i�� ipi� The
required inequality follows by a simple manipulation�
���� c� Induction on n� Let n �� and let d�� � � � � dn satisfy the condi�tion� Then there is some di � � and also some dj � � for a simple notation�assume dn � �� dn�� � �� By the inductive hypothesis� we construct a treewith score d�� � � � � dn��� dn���� and we connect a new end�vertex to thevertex number n� �������� Divide the sequences into two groups� those beginning with andthose beginning with �� and sort both groups recursively� In an actualimplementation of the algorithm� the sequences themselves are not actuallymoved� one only works with suitable pointers to them�
������ The code of a tree on n vertices has length �n� Hence there are atmost �n distinct codes�
������ Prove that the mark of any single vertex is changed at most log� ntimes�
������ Let the graph G be given by lists Sv of edges containing each vertexv � V G� Maintain a doubly linked list N of all edges going between theset Vi and its complement� and� moreover� for each edge belonging to Nkeep a pointer to its occurrence in N � If the newly added vertex yi hasdegree d then all the lists and pointers can be updated in Od time�
�����a� Induction on the number of vertices� Show that for every edgefv� v�g � ET � an ordering v�� v�� � � � � vn of the vertices exists such thatv� � v� vn � v�� and the distance of vi and vi�� is at most �� i � �� �� � � � �n� �������� Use Kruskal�s algorithm for the weight function �w������� The computation of Kruskal�s algorithm is determined uniquely andit gives some minimum spanning tree� The proof of correctness shows thatany other spanning tree has a strictly larger weight�
������ In each group of edges of the same weight� put the edges of T �rst�Let T � be the tree computed by Kruskal�s algorithm� let e��� � � � � e
�n�� be its
��� Hints to selected exercises
edges in the order of their selection� and let e�� � � � � en�� be the edges of Tnumbered according to the chosen ordering� For contradiction� let k be thesmallest index with ek �� e�k� We get we
�k � wek� but from the proof in
the text we have we�i � wei for all i� and so T is not minimum�
������ Follows from Exercise ��
���� a� If v has degree � then there exist edges fv� u�g and fv� u�gwith angle � � degrees� Show that one of them can be replaced by theedge fu�� u�g����� b� Prove and use the fact that if ABCD is a convex quadranglethen jABj� jCDj � jACj � jBDj and jBCj� jADj � jACj� jBDj� Showthat two crossing edges may be replaced by two noncrossing edges�
������ Cover the unit square by anpn�pn chessboard� Order the squares
of the chessboard into a sequence s�� s�� � � � � sn so that consecutive squaresare adjacent� Construct a path on the given points by �rst going throughall points in s�� then all points in s�� etc�
������a� Let EM be a maximum matching and EG the matching foundby the greedy algorithm� To each edge e � EM assign the �rst edge of EG
intersecting it� Each edge (e � EG is thereby assigned to at most two edgese�� e� � EM with we�� we� � w(e�
������b� Let e�� � � � � ek be the edges selected by the greedy algorithmand (e�� � � � � (et edges of some smallest edge cover� Let k� � jfi� ei � e� �� � ��ei�� � gj� and similarly t� � jfi� (ei� (e��� � �� (ei�� � gj� We havejV j � k�k� � t� t�� Key observation� in the steps of the greedy algorithmfor i � k�� at least one point of each edge (ej contributing to t� must havebeen covered� and hence k� �
� t�� From this we get k � t � t� � k� �t� �
� t� � �� t�
������� Let V � f�� �� � � � � �k�� � �g � fa�� a�� b�� b�� � � � � bkg� The vertexa� is connected to �� �� �� � � �� a� to �� �� �� � � �� bi to �
i � �� �i� � � � � �i�� � ��a�� a� are� moreover� connected to all the bi� The greedy algorithm selectsall the bi while the optimum dominating set is fa�� a�g������a� Prove that after the ith phase� every component has at least �i
vertices�
�����b� For each component� maintain a list of its outgoing edges� Ineach phase� each list can be traversed and the edge of minimum weight init can be found�
�����a� Fig� ����
�����b� Graphs G�� G� as in a can be glued together� For instance�remove an edge fa� bg adjacent to the outer face of G�� an edge fc� dgadjacent to the outer face of G�� and add edges fa� cg and fb� dg������� By induction on the number of edges� Consider a vertex v of degreeat least �� and look at two adjacent edges incident to v in the circularorder around v� If possible� choose these edges so that they go into distinct
Hints to selected exercises ���
components of G� v� Replace these two edges by a single edge connectingthe other ends� It may be advantageous to allow for graphs with multipleedges�
������ On each ��tuple of vertices we have a copy of K�� and some two ofits edges must cross� We thus obtain at least
�n�
�pairs of crossing edges�
One pair of crossing edges has been counted in n� � copies of K��
�����a� Choose a disk D such that k �D is a segment� From any pointof R� nk we can reach D by a polygonal arc going along k� But D nk hasat most two equivalence classes since any two points on the same side canbe connected by a segment�
������ First� one has to handle the case when G is not ��connected� For a��connected G� prove that one can add a diagonal into a face bounded byat least � edges� But one has to be careful to create no triangle� Probablyit is necessary to discuss several possible cases�
�����a� Let us say that a dot with k � � outgoing edges contributes�� k degrees of freedom� Initially� there are �n degrees of freedom� �nallyat least �� and each move reduces the number of degrees of freedom by ��
�����c� Show that in the �nal position� there is exactly one �unused�arm of a cross protruding into each face� The total number of unused armsremains constant during the game� and therefore there are �n faces in theend� Each move either connects two components into one or increments thenumber of faces by ��
���� a� By induction on n� prove e � v � f � �� when inserting a newline distinguish newly created intersections and already existing ones�
���� c� Derive e �f � n from b� If di is the number of lines passingthrough the ith intersection� we calculate
Pdi � e � n since each edge
contributes by � ends� except for the �n semiin�nite rays� By substitutingfor f from a we �nally get
Pdi � �v � ��
������ Assume connectedness� Let a red$blue corner be a pair f� v� wheref is a face and v is a vertex adjacent to f such that if we go along theboundary of f clockwise counterclockwise around the unbounded face� vis preceded by a red edge and followed by a blue edge� By double�countingand by Euler�s formula� show that there is a vertex with at most one red$blue corner�
������ Proceed by induction on the number of vertices� For a given graph�remove a smallest�degree vertex� color the rest� and put the vertex back�
������ A subgraph of an outerplanar graph is outerplanar� Hence by Exer�cise � it is enough to show that an outerplanar graph always has a vertexof degree � �� This can be extracted from Euler�s formula using the factthat some face has at least n edges adjacent to it�
������ Show that G � � and use Exercise �������b� One can even take a tree�
��� Hints to selected exercises
�����c� Add su�ciently many new leaves to adjust the degrees�
������a� By induction on the number of edges� Consider a face F andthe set of edges EF lying on its boundary� Show that the degrees of allvertices in the graph V�EF are even� Delete the edges from EF � color byinduction� put EF back� and recolor the face F by the other color�
������b� Color the faces by � colors� The number of edges can be countedas the sum of the circumferences of the faces of one color� and also asthe sum of circumferences of the faces of the other color� But one way ofcounting gives a number divisible by �� the other a number not divisibleby ��
������b� For one class� take k vertices v�� � � � � vk� where vi has the listLvi � fki����� ki����� � � � � kig� For each set S containing exactlyone element from each of the Lvi� put a vertex vS with the list LvS � Sin the other class�
������� In the inductive step� distinguish two cases� If there is an edgefvi� vjg with vi and vj lying on the cycle C but not consecutively� split Galong that edge� Otherwise� remove vk and adjust the lists of its neighborssuitably�
������ De�ne a graph on the faces exactly as in the proof of Sperner�slemma�
������ Imagine two tourists on the same day� one ascending� one descend�ing�
������ Yes only for b� e� In a� use a rotation around the center� in d�let fx be the point of the sphere antipodal to x�
�����a� Imitate the proof of the planar version� Connect by an edgetetrahedra sharing a face labeled �� �� �� and use the planar version toshow that the degree of the outer face is odd�
�����b� Ensure that a is much farther from c than b from d�
�����c� By contradiction� If Betty has a winning strategy� Alice will makeher �rst move arbitrarily and �nd herself essentially in Betty�s situationone marked node from the �rst move can only help� Then she will useBetty�s winning strategy�
�����b� Show that if Alice starts then Betty has a very simple strategyto force a draw�
������ An independent set systemM satis�esP
MM�njMj
��� � �� and thesystem
�X
bn��c�gives equality� Hence all the sets in a systemM of largest
size have size bn��c or dn��e thus� for an even n we are done� Show thatifM has t sets of size bn��c and � t �
�n
bn��c�thenM has �
�n
bn��c�� t
sets of size dn��e������� For an automorphism h� de�ne a mapping f �X � X � where fx isthe y such that hfxg � fyg� Show that h � f� hence all automorphismscome from permutations and there are n� of them�
Hints to selected exercises ���
�����a� Apply Sperner�s theorem on the set system ffi� �i � �g�P
�iai ���� �g������� Let n � p�p� � � � pn be the decomposition of n into prime factors� Toa divisor d � pi�pi� � � � pik assign the set Md � fi�� � � � � ikg � f�� �� � � � � ng�then d�jd� �Md� �Md� � Use Sperner�s theorem�
���� a� By induction on c� Take the set of all minimal elements as the�rst antichain� and show that by removing these elements� c drops by ��
���� b� An elementary proof can be found in Van Lint and Wilson ���Theorem ����
������ De�ne i � j if and only if i � j and ai � aj � A chain in the posetf�� � � � � ng�� corresponds to an increasing subsequence� an antichain toa decreasing subsequence�
������ Imitate the proof forK���� the only di�erence being that one vertex vcontributes at most t� � elements to M ������� Instead of fx � xx � ��� consider the function fx whichequals for x � � and xx� �x� ��� for x � �� Show it is convex� anduse this similarly as for excluded K����
�����a� The graph with vertex set P �L and edges corresponding to thepairs being counted contains no K����
�����b� This time� the graph K��� is excluded�
������ Proceed as we did for the lower bound for the number of noniso�morphic graphs in Section ���� Use Theorem ����� and the estimate for n�from Theorem ������
������ Count spanning trees containing a given edge of Kn� By symmetry�this number is the same for all edges� Use Cayley�s formula�
������ From each spanning tree of Kn� we can remove one edge in n � �ways� this yields a pair of trees� Conversely� from a spanning tree on somek�point subset of the vertices plus a spanning tree on the remaining n� kvertices� a spanning tree of the whole Kn can be manufactured by addingone edge� in kn� k ways�
������ Given a spanning tree T of G� consider the subgraph of G� consistingof the edges not crossed by the edges of T � and prove that this is a spanningtree of G�� See Lov'asz ��� for details�
�����a� It�s for n odd� For n even we have n� � � leaves and
n� � � ver�
tices of degree � by induction� We thus sum the expression n� ����n����
over all choices of a vector d�� � � � � dn with di � f�� �g andP
di � �n� ��By the substitution ki �
�� di � � we see that the number of summands
equals the number of n� � ��element subsets of an n�element set� and
therefore the answer is n� ��� nn����
���n�����
�����b� Perhaps the easiest solution uses generating functions� The an�swer is the coe�cient of x�n�� in the expression n � ��x � x� � �
�x�n�
�� Hints to selected exercises
which can be found using the multinomial theorem part a can be solvedsimilarly as well�
�����a� Both sides of the equality count the number of pairs spanningtrees T� T � where degT n � k� degT�n � k � �� and T � arises fromT by the following operation� pick an edge fi� jg � ET with i �� n �� j�delete it� and add either the edge fi� ng or the edge fj� ng� depending onwhich of these edges connects the two components of T � fi� jg� From oneT we can get n � � � k di�erent T �� and one T � can be obtained fromkn� � di�erent T ������c�
PkNk happens to be the expansion of n����n�� according
to the binomial theorem�
������ Imagine that you send two pedestrians from the vertex i in thedirected graph of f � One of them traverses one arrow per minute� the otherone maintains the speed of one arrow in two minutes� Think about thetimes the pedestrians will meet at the same vertex�
������ The inequality degT i mi � � is easy to see� At the same time�we have
Pimi � n� � and PidegT i� � � �n� �� n � n� �� and
so equality must hold for all i�
�����a� All row sums of Q are �
�����b� Since T G � � we have detQ�� �� by Theorem �����������c� The sum of the rows of Q corresponding to the vertices of acomponent of G is � and hence the vector space generated by the rows ofQ has dimension � n� �������d� The kernel of the linear mapping x �� Qx contains �� �� � � � � �because the sum of rows is � and the kernel is one�dimensional by b�
�����e� The product of the ith row of Q and the ith column of Q� is theexpansion of detQ according to the ith row� Use detQ � � Other entriesin the product QQ� are expansions of determinants for matrices in whichone row is repeated twice� hence also �
�����b� ����
������ The result is nm��mn���
������ For one implication� compute the determinant of the incidence ma�trix of an odd�length cycle� The required property ofM for bipartite graphscan be proved by induction� similarly as in the proof of Lemma ������
����c� Possibilities� L � fXg� L � fX� fagg for some a � X � andL � fX n fagg � ffa� xg� x � X n fagg for some a � X � In a proof�Exercise � may be useful�
����� Show that � points of L� nL� and � points of L� nL� together forma con�guration F as in axiom P �
����� At most � sets can contain any given point�
Hints to selected exercises ���
����� Yes� Draw � lines in the plane in general position no � parallel� no �intersecting at a common point� Let the intersections represent stops andthe lines bus routes�
��� a� One pair is in at most one set� One set covers�n���
�pairs� The
total number of covered pairs comes out the same as the number of allpairs� and hence all pairs must be covered�
��� b� If there were more such sets they have more than n� � n � �points altogether�
��� c� Double�count the pairs x� L� x � L� and use b�
��� d� Count that there are n��n�� distinct lines intersecting a givenline�
����� Fix a point a � A� The n � � lines containing it cover all pointsof X � and each of them has at most one point of A besides a�
�����a� Delete the points of one� arbitrarily chosen� line�
�����b� Transitivity� suppose A� k A�� A� k A�� and x � A��A�� ThenA� and A� are two lines passing through x and parallel to A�� contradictingthe third axiom�
�����c� For showing that two lines A�A� have the same cardinality�construct a bijection using lines parallel to some line xy with x � A andy � A��
�����d� For each equivalence class of k� add one new point �at in�nity��add it to the lines from that class� and also make all the new points into aline� Check the axioms�
����a� To given t orthogonal Latin squares� add one square with all theentries of the ith row equal to i� i � �� �� � � � � n� and one square having allthe entries j in the jth column� j � �� �� � � � � n�
����b� In order that a liberated square be orthogonal to another� ithas to contain each i � f�� �� � � � � ng exactly n�� Permute entries of thegiven t � � orthogonal liberated squares the same permutation in eachsquare in such a way that the �rst square has all numbers i in the ith row�i � �� � � � � n� Then permute entries inside each row again� in the same wayfor all squares so that the second square has all the j in the jth column�Check that the remaining t squares are Latin�
����� n� � the number of permutations with no �xed point� ����a� Let the vertex classes be A and B� double�counting givesP�
di�
��
�n�
�� where the di are the degrees of the vertices in A� and we
have m � jEGj �Pi di� This time one has to calculate exactly� Cauchy$
Schwarz gives m� � nP
d�i � �nP�
di�
��nm � n�n� ��nm� Solve the
resulting quadratic inequality for m�
�����a� A function of n variables de�nes two functions of n�� variables�one for xn � and one for xn � �� One can proceed by induction on n�
��� Hints to selected exercises
������ Each weighing has � possible outcomes� and hence � weighings canonly distinguish one among �� possibilities�
������ Code all possible ways of the cars passing through the depictedsystem of rails� e�g� �a car from rail A goes to rail I� car from A to C� carfrom I to C� car from C to II� � � � �� Show that at most Cn possible codesexist for a large enough constant C� hence there are at most this manypossible car orders on rail B� and this is smaller than n� for n large�
�����a� P A� � � � � � An �P
���I�f������ng��jIj��P�T
iI Ai
��
�����b� All the three proofs of inclusion$exclusion in Chapter � generalizeeasily�
������ For a disconnected graph� there exists a nonempty proper subsetA of vertices such that there are no edges between A and its complement�Calculate the probability of this event for a �xed A� and then sum up overall possible choices of A�
���� � If we replace some of the Ai by their complements we still havea collection of independent events� and hence the intersection of all theseevents has a nonzero probability� In this way� one can produce �n disjointevents with nonzero probability�
������ It�s �� � Let the children be A and B� There are � equally probable
possibilities� A�boy� B�boy� A�boy� B�girl� A�girl� B�boy�
������ Show � E�f �E �f ��
�� E
�f���E �f �
��
������ Use indicators� Let Ai be the event ��i � i�� Result� E �f � � ��
�����a� Let Ai be the event �� is contained in a cycle of length i�� Showthat P Ai �
�n � and express the desired expectation as
Pni�� i � E �IAi
��
�����b� Let Aij be the event �j lies in a cycle of length i�� By parta� we have P Aij �
�n � Check that the resulting expectation equalsPn
i�j���iE
�IAij
��
������ It�s better to count boundaries among runs� The probability that agiven position between two tosses is a boundary is �
� �
������ We have � �P
� P f�gX� P
��X���t� P f�gt� �t�P f� � !� X� t�g������� A Kr�free graph with at least r� � vertices and with the maximumpossible number of edges has to contain a Kr��� Tear o� a Kr�� and countthe number of deleted edges�
�����b� Let L be the set of numbers smaller than the dividing elementand R the set of the larger numbers� Show that in both the consideredalgorithms� the number minjLj� jRj has the same probability distribution�This number fully determines the sizes of the two pieces in the recursion�
������ Let R be the r circles that remain black� c the circle that was coloredand emptied again� and SR the set of empty circles seen by the observerfor a given R� Let p be the probability of c � SR� Since c is a random
Hints to selected exercises ���
element of R � fcg we get p � ��r � �� On the other hand� since wecould �rst pick R and then c at random among the remaining n� r emptycircles� p is the average� over all choices of R� of jSRj�n � r� Hencep � E �jSRj� �n� r�
������ There are at most � peaks at level � Compute the expected numberof peaks at level for a random sample R of the lines in two ways as inthe proof in the text�
������� In order to get the term xk�� � � � xkmm in multiplying out n paren�theses� we have to choose k� parentheses from which we take x�� � � � � kmparentheses from which we take xm� The number of such choices is just themultinomial coe�cient�
������� Begin with the equality �� xn� � xn � �� x�n�
������� ax � �� x��x�� x��� � x� � x � x���� x�� Use thegeneralized binomial theorem�
����� a� The generating function is ���� x�� x��� x��
������d� Result� ��m�n��m
��
�������� For � � k � n � r � �� there are�n�kr��
�subsets with smallest
element k� so we need to sumP
k k�n�kr��
�� This can be done for instance
by considering the equality �xr�����xr��x���x�� � xr���xr�� andcomparing the coe�cients of xn� Alternatively� if we denote the expectationby fn� r� we have the recurrence fn� r � p � � � p� � fn � �� rwith p � r
n since either R contains �� which happens with probability p�or it can be regarded as a random r�element subset of f�� �� � � � � ng� Thenfn� r � n��
r�� follows by induction�
�������a� For the continuity� we need to prove that for x� � � � �� wehave limx�x� jax�ax�j � � Use the estimate jxi��xij � jx��xjxi��
� �xi��� x� � � �� xi�� � jx� x�jimi��� where m � maxx� x��
�������c� For instance� ai � ��i��
�������a� First� show by induction that each derivative of the function
f at a point x �� has the form Rxe���x� � where Rx is a ratio of twopolynomials� Then prove that each derivative is at �
�������b� If it were a power series� its coe�cients could be expressedusing the derivatives� and hence they would have to be all s�
�������a� For the ring arrangement� � ln�� x�
�������c� Dx � ����Ax�
�������d� Ex � eA�x��
�������e� The exponential generating function is ex����
�������� Use part d with the subgroups arranged into unorganized crowdswith at least one member� i�e� Ax � ex � �� The result is eex���
�������� The exponential generating function is x���� � x���� � x������The answer is ��� � the coe�cient of x���
��� Hints to selected exercises
�������a� Such arrangements are in a bijective correspondence with per�mutations� since they encode the cycles of the permutation�
�������b� The result is e� ln���x��x � ��x�x�� � � ���x����x�����x���� � � � ��������� Let an� bn be the number of such sequences ending with � � re�spectively� Derive recurrence relations for an and bn� Result� the Fibonaccinumbers�
������� Induction on n� Call a representation of n as a sum of distinctFibonacci numbers reduced if it uses no two consecutive Fibonacci num�bers� Any representation can be converted to a reduced one by repeatedlyreplacing the largest two consecutive Fibonacci numbers by their sum� Togo from n to n � � consider a reduced representation of n� add a � to it�and make it reduced again� Let us remark that a reduced representation isunique�
������� Consider the sequence bn � log� an�
������� A suitable expression isP�
k�� xk� � �xk � ��� � x � �x� �
�� ���� � x � ���� �x�� and the formula is �
��n � �
� �
����� � n� ���n���
������� It satis�es the recurrence an�� � �an�� � an with a� � a� � ��
�������� Show that xn � ��p��n���p��n satis�es xn�� � ��xn���
xn with initial conditions x� � �� x� � �� and hence is integral for all n�Further use
p��� � � ���
�������� The equationpx� ��px � y solves to x � �� y���y� �
y � �� Hence it su�ces to show that this x is an integer for y � p���n�
We get x � a�n where an ���
�p� � �n � p�� �n�� Find a recurrence
for an and show by induction that for n even� an is integral� and for n odd�an is an integer multiple of
p��
�������� Let un denote the number of such sequences beginning with aor b� and let vn be the number of such sequences beginning with c or d�One gets the recurrences un � un�� � �vn�� and vn � �un�� � �vn���Write down the corresponding equations for the generating functions uxand vx� solve them� and calculate the coe�cients� The result is un�vn �p� ���p� �� � �
p��n�� �
p� ���p� �� ��
p��n���
�������a� The number is Fn���
�������b� Recurrence� an�� � an�� � �an�� � �an� a� � �� a� � ��a� � �� an � �p
�� �
p�n�
�������c� Let an be the required number� and let bn be the numberof ways to �ll an n � � rectangle the longer side is vertical with thetop left corner square removed� Recurrences� an � an�� � �bn�� � an���bn � an���bn��� a� � a� � �� b� � b� � � Generating function equations�bx � xbx � x�ax� ax � � � xax � �bx � x�ax� From this weget ax � �� x��� �x� x� and an � ��� � � � ��� ��� � � �n�
Hints to selected exercises ���
�������a� For the language with no consecutive letters a� write A �fag� B � fbg� Then B��A�B�B���B��A�B�B���A expresses the desiredlanguage as a very regular one�
�������b� If ax is the generating function of L� and bx of L�� thenaxbx is the generating function of L��L�� ���� ax is the generatingfunction of L��� and ax�bx is the generating function of L��L� providedthat L� � L� � ��������c� One can go via deterministic �nite automata� see a textbookon automata and formal grammars�
�������b� Show that the sequences whose jth term is � and the otherterms among y�� � � � � yk�� are � for j � � �� � � � � k � �� form a basis��������c� To show linear independence� it su�ces to check that the vec�tors formed by the �rst k terms of the considered sequences are linearlyindependent� To this end� one can use the criterion of linear independencevia determinants� This leads to the so�called Vandermonde determinantusually discussed in linear algebra courses�
�������e� Perhaps the simplest method is using the order of growth ofthe sequences� If the sequences were linearly dependent� the fastest�growingone could be expressed as a linear combination of the more slowly growingones� which is impossible� A problem in this approach appears only if thereare several complex roots with the same absolute value� This case can behandled separately� for instance using the Vandermonde determinant as inthe hint to c� Alternatively� one can consider the determinant for the �rstk terms as in c and prove that it is nonzero�
������� Encode a binary tree with n vertices by a string of On lettersand digits� say� thereby showing that bn � Cn for some constant C�
������a���nn
��
������b� A path that never goes below the diagonal encodes a binary treein the following manner� Divide the path into two parts at the point whereit reaches the diagonal for the �rst time the second part may be empty�Remove the �rst and last edges from the �rst part and leave the secondpart intact� Both parts then encode the left and right subtrees recursivelyan empty path encodes an empty tree�
������c� For the description of the solution� we introduce coordinates�A is � � B is n� n� Extend the chessboard by one column on theright� Show that the paths that do reach below the diagonal are in abijective correspondence with the shortest paths from A to the pointB� � n� �� n� �� Follow the given AB�path until the end of its �rstedge lying below the diagonal� and �ip the part of the path from that pointon around the line y � x � �� This yields an AB��path� Check that thisde�nes a bijection�
������� Find a bijective correspondence with paths on the chessboard notreaching below the diagonal from the preceding exercise�
��� Hints to selected exercises
����� b� c�n�� � bn� A bijection between the planted trees consideredin the exercise and the binary trees considered in the text is obtained bydeleting all the leaves of a given planted tree�
������a� Result� tn � bn���
�������� An old tree either is the root itself or arises by connecting somek planted trees with at least � vertices each to the root� whence sx �x� x��� tx � x�
������a� Let ai be the number of trajectories starting at � and �rst en�tering after i moves� The required probability is a �� � Derive the relationax � x � xax�� The value of ai can also be calculated explicitly� forinstance using the Catalan numbers�
������b� The catch is that S� is in�nite although � will be reachedalmost surely� the expected time needed to reach it is in�nite��
������a� Such an ordered partition can be encoded by dividing thenumbers �� �� � � � � n into k segments of consecutive numbers� De�ne ak � ��element subset of f�� �� � � � � n � �g by taking all numbers that arelast in their segment except for n�
������b� A direct solution is as in a all subsets of f�� �� � � � � n � �g�The generating function in a is xk��� xk� and the sum over all k �is x��� �x�������a� � � x� � x� � � � � � xn�
������c� Find a bijection between all partitions of n with k distinctsummands and all partitions of n� �
k�
�with k summands not necessarily
distinct� Then use the lower bound method demonstrated in the text�
������c� The generating functions are � � x� � x�� � x� � � � and����x��x���x� � � �� Multiply both the numerator and denominatorof the �rst expression by � � x� � x�� � x� � � �� This leads to theexpression �� x��� x��� x � � ���� x�� x��� x� � � �� andthe factors with even powers of x cancel out� For a direct argument see e�g�Van Lint and Wilson ����
������a� p� � p� � � � �� pm�
������b� There is a bijection mapping such trees to partitions of m� ��the sizes of the components after deleting the root determine the partitionof m� ��������c�
Qmi�� ���� xipi �
������d� Proceeding as in the proof of Theorem � ����� one gets ln rn ��n lnx � P�
j�� Pnxj�j� In the text� it was shown that lnPnx �
Cx��� x� Choose x � � � clnn for a small enough c � � Then �n lnx
is about nc lnn � and it still requires some ingenuity to show that the sumP�
j�� eCxj����xj��j has about the same order as its �rst term which is
about nc�C�
Hints to selected exercises ���
������e� Consider trees of a special form� where the root is attachedto k subtrees with q leaves each� Their number is at least pkq�k�� Use theestimate for pn derived in the text� and adjust k and q suitably�
������b� This is essentially a problem dual to Exercise ������
������� Each row of the matrix AB is a linear combination of rows of thematrix B with coe�cients given by the corresponding row of A� and hencerAB � rB�
������� The regularity of a square matrix is equivalent to its determinantbeing nonzero� and the de�nition of determinant is independent of the �eld�The rank of a nonsquare matrix can be expressed as the size of the largestregular square submatrix�
������a� If it had rank � n then the system of linear equations Mx � has a nonzero solution� and such a solution gives xTMx � �
������b� M is a sum of a diagonal matrix D with positive elements onthe diagonal and of a matrix L with all entries � � � For each nonzerox � Rv we have xTDx � and xTLx �������a� If A is the incidence matrix of the set system� them ATA is asum of a matrix Q with all entries equal to q and of a diagonal matrix Dwhose diagonal entries are jCij � q � assuming jCij � q� Hence ATA ispositive de�nite and consequently regular�
������b� In the situation of Fisher�s inequality� consider the set systemdual to V�B and apply a to it�������b� By induction on k� prove that if E is a union of edge sets of kbipartite graphs on the vertex set f�� �� � � � � ng� then there exists a set ofat least dn��ke vertices with no edge of E on it�������� Let A � aij be the n� n matrix with aij � or � depending onwhether team i won with team j� The condition translates to Ax �� for allnonzero vectors x arithmetic over GF �� hence A is regular� For n odd�the nonzero terms in the expansion of detA as a sum over all permutationscan be paired up and hence detA � �
������b� False�
������� If rx has degree d� calculate rz�pzqz for z chosen uniformlyat random in the set f�� �� � � � � �dg� say� If the result is then rx�pxqxis identically with probability at least �
� �
������� Suppose that � S� Set a b � for all a� b � S with a singleexception� x y � x for some x� y � S n f g�������a� Show that if all triples a� b� c with b � G�k� are associativethen also all triples with b � G�k��� are associative�
������c� Start with G� � fg�g for an arbitrary g� � S� maintain hGki�and set Gk�� � Gk � fgk��g for some gk�� � S n hGki� By b� the sizeof hGki doubles in each step� Showing that hGki can be maintained in theclaimed time still requires some ingenuity�
��� Hints to selected exercises
Index
�V�
�� ���
Xk
�� ��������
nk
�� ���n
k������km
�� ��
�� � �� � P� �� ��Q� �
a j b� �������a� b� ��a� b�� �bxc� �dxe� �fx� yg� � x� y� � � ���X � ���� ���� ��jX j� ��� ��Ex� �X�� ��X +�Y � ��X � Y � ��f� � �g� � R�x�� ��R S� ��xRy� ��fX� ��fx� ��f��� � f �X � Y � ��f �X��Y � ��f �x �� y� ��f � g� ��AT � ���G� ,e� ��������
G%e� ��������G� e� ��������G� v� ��������G�e� ��������G �� H � � ������ab� ���!�� ��"�� ���n� ����G� ����������� ��������p� ����� ���Ex� ��� ��computation� � Ex� �
�n� �������
AG� � ������acyclic relation� ��Ex� �adjacency matrix� ��� � ������adjacent vertices� ��a�ne plane� ���Ex� � � ����
���Ex� �algebra� linear application�
���$���� ���$�������$���
algorithmBor*uvka�s� ��������greedy� ��������� ����
���Ex� � ����Ex� ��� ���Ex� ��
Jarn')k�s� ��������Kruskal�s� ��������Prim�s� see Jarn')k�s algorithmQUICKSORT� �� $���randomized� ���sorting� ��Ex� �� �� $���
� Index
antichain� ���� ���Ex� �antisymmetric relation� � arc� ���arc�connected set� ���arithmetic mean� ��associative operation� ��� ���asymmetricgraph� � �Ex� �tree� �� Ex� �
asymptotic analysis� ��automorphismof a graph� � �Ex� �of a poset� ���� ���Ex� �
band� M&obius� �� basis� �� Bell number� ��Ex� ��
� �Ex� ��Bernoulli�s inequality� � Bertrand postulate� ��Betti number� see cyclomatic
numberbijection� �������binary operation� ���� ���binary tree� ���$���Binet$Cauchy theorem�
��������binomial coe�cient� ��$���
���$���� ���Ex� �estimate� ��$��generalized� � �� ����
binomial theorem� �������combinatorial meaning� ���generalized� � �� ����� ���
bipartite graph� � �� ���Ex� �����Ex� �
complete� � �block design� ���$���Bonferroni inequality� � Boolean function� ����
���Ex� �Bor*uvka�s algorithm� ��������Borsuk$Ulam theorem� � �bottle� Klein� �� bounded face� ���
bridge� ���Brouwer�s theorem� � �������
�� Ex� �
C� ���CG� ���Cn� � Cn� ��������carrier� ���Cartesian product� ��Catalan number� ���$�� Cauchy$Schwarzinequality� �� ������
���Ex� �Cayley�s formula� ��������center of a graph� ���centroid� �� Ex� �chain� ��Ex� �� ���symmetric� ���
characteristic function� � characteristic polynomial� ���chromatic number� ���������
���Ex� �list� � �Ex� ��
circuit� see cyclecirculation� �� space� ���
closure� transitive� ��Ex� �codeof a tree� ���Pr&ufer� ���
coe�cientbinomial� ��$��� ���$����
���Ex� �generalized� � �� ����
multinomial� ��coloringof a graph� ��������of a map� ���$� �
commutative operation� ������
compactness� � �complement� ���Ex� �completebipartite graph� � �
Index ��
graph� � complexity of algorithm� ���component� � �compositionof functions� ��of relations� ��
con�guration� tactical� ���connected graph� � �connected set� ���connectednessstrong� ��������weak� ��������
connectivity� ���contraction� ���convexbody� ���function� ���Ex� �
cover� edge� ���Ex� ��critical ��connected graph�
���Ex� �cube graph� ���� ���Ex� �curve� Jordan� ���cut� ���space� ���
cycle� � elementary� ���Hamiltonian� ���Ex� ��
���Ex� �in a graph� � �of a permutation� ��� ���space� ���
cyclomatic number� ���
dG�� �� � �De Bruijn graph� �� de Moivre�s theorem� ��Ex� ��
�� de Morgan laws� ��decreasing subsequence�
���Ex� �degG�� ���deg�G�� ���deg�G�� ���degree of a vertex� ���degree sequence� see score
dependence� linear� �� depth��rst search� � �derangement� ��design� block� ���$���determinant� ���expansion� ���
diagonal� ���matrix� ���relation� ��
diagramFerrers� ���Hasse� ��
diameter� ���Ex� �di�erence� symmetric� ���digraph� see directed graphDilworth�s theorem� ���Ex� �dimension� �� directedcycle� ���edge� ��������graph� ��������tour� ���
distance in a graph� � �distributive operation� ��� ���dominating set� ���Ex� ��double counting� ���double�counting� ��� � �$����
���Ex� �drawing of a graph� ��������dualgraph� ��������spanning trees� ���Ex� �
projective plane� ���duality� ���� ���
E � ���E� �� �����e� ��EG� ��ear decomposition� ���edge� �������connectivity� ���contraction� ���cover� ���Ex� ��directed� ��������
�� Index
multiple� �� subdivision� ��������weight� ���
elementlargest� ��Ex� �maximal� ��Ex� �minimal� ��Ex� �smallest� ��Ex� �
elementarycycle� ���event� ���row operation� ���
emptyproduct� ��set� ��sum� ��
end�vertex� ���equivalence� �������maintaining� ���������
���Ex� �number of� ��Ex� �
Erd/os$Szekeres lemma����Ex� �
estimateof binomial coe�cient� ��$��of factorial� ��$��� � Ex� �
Eulerformula� ��������for trees� �� �����
function� ��$��� ��Ex� �number� ��
Euleriangraph� ���$���� ���Ex� �tour� ���
even set� ���������number of� ���������
event� ���elementary� ���
events� independent� ���$���excentricity� ���exG�� ���expansion of determinant� ���expectation� ���$���� ���de�nition� �� �����linearity� ��������
exponential generating function�� �Ex� ��
extension� linear� ��Ex� ����Ex� ��
extremal graph theory� ���
face of a planar graph� ���face of a polytope� ���factorial� ��divisibility� ��Ex� �estimate� ��$��� � Ex� �
family of sets� ��Fano plane� ���� ���Ex� �father in rooted tree� ���Ferrers diagram� ���Fibonacci number� � �$����eld� ����nite probability space�
���������nite projective plane� �� $���de�nition� �� ������
���Ex� �� ���Ex� �����Ex� �
existence� �� $���order� ��������
Fisher�s inequality� �� ����������Ex� �
�xed point� ��� ���Ex� �theorem� � ������� � ������
forest� ���spanning� ���
formulaCayley�s� ��������Euler�s� ��������for trees� �� �����
Heawood�s� ���Leibniz� ��Ex� ��logical� ���� ���Ex� �Stirling�s� ��
fractions� partial� �� Freivalds� checker� ���������function� �������bijective� �������Boolean� ���� ���Ex� �characteristic� �
Index ��
convex� ���Ex� �Euler� ��$��� ��Ex� �generating� ���$���exponential� � �Ex� ��of a sequence� � � ����operations� � �$� �
graph� ���� ���Ex� �����Ex� �
identity� ��Ex� �injective� ��monotone� ��Ex� �number of� �������one�to�one� �������number of� �������
onto� �������number of� ��Ex� �
period� ���Ex� �surjective� ��
GF q� ���GF �� ���Gn� ��������gcdm�n� ��generalized binomial theorem�
� �� ����� ���generating function� ���$���exponential� � �Ex� ��of a sequence� � � ����operations� � �$� �
genus� ��������geometric mean� ��golden section� ���� ���Graham$Pollak theorem�
���������graph� �������asymmetric� � �Ex� �bipartite� � �� ���Ex� ��
���Ex� �complete� � �
chromatic number� ������������Ex� �
coloring� ��������complete� � connected� � �De Bruijn� ��
diameter� ���Ex� �directed� ��������drawing� ��� ��������dual� ��������spanning trees� ���Ex� �
k�edge�connected� ���Eulerian� ���$���� ���Ex� �Heawood� ���Ex� ��� ���isomorphism� � ������Kneser� � �Ex� �line� ���Ex� �list chromatic number�
� �Ex� ��metric� � �number of� ��Ex� ��� � �of a function� ���� ���Ex� ��
���Ex� �of incidence� ���� �� orientation� ���oriented� ���outerplanar� ���Ex� �Petersen� � �Ex� �planar� ���$� �maximal� ��������number of edges� ��������score� ��������
radius� ���Ex� �random� ���������
���Ex� �� ���Ex� �randomly Eulerian� ���Ex� �regular� ���Ex� ��strongly connected� ��������topological� ��������tough� ���Ex� �triangle�free� ���Ex� ���connected� ���$���critical� ���Ex� �
k�vertex�connected� ���weakly connected� ��������with loops� �� with multiple edges� �� without Kk� ���without K���� ���� �� without K��t� ���Ex� �without K���� ���Ex� �
�� Index
greedy algorithm� ������������� ���Ex� � ����Ex� ��� ���Ex� ��
Gr&otsch theorem� ���Ex� �group� ���
Hamiltoniancycle� ���Ex� �� ���Ex� �path� ���Ex� �
handshake lemma� ���applications� � �$� �
harmonicmean� � Ex� �number� �������� ��Ex� ��
Hasse diagram� ��hatcheck lady problem�
�������� � �Ex� ��recurrence� ��Ex� ��
��Ex� �Heawoodformula� ���graph� ���Ex� ��� ���
hydrocarbons� number of����Ex� ��
hypergraph� ���hypothesis� inductive� ��
In� ���identityfunction� ��Ex� �matrix� ���
image� ��incidencegraph� ���� �� matrix� ���� ���Ex� �� �� �
���inclusion$exclusion� ��$���
���Ex� �applications� ��$��
increasingsegment of a permutation�
��Ex� �subsequence� ���Ex� �
indegree� ���independence� linear� ��
independentevents� ���$���set� ���set system� ���
indicator� ��������induced subgraph� � ������induction� ��inductivehypothesis� ��step� ��
inequalityBernoulli�s� � Bonferroni� � Cauchy$Schwarz� �� ������
���Ex� �Fisher�s� �� �������
���Ex� �Jensen�s� ���Ex� �LYM� ���Markov� ���Ex� �
inf A� ��Ex� ��in�mum� ��Ex� ��injection� ��inner face� ���integers� �integrality conditions�
���������intersection of level k� ���$�� �
���Ex� �inversion of a permutation�
��Ex� �isomorphismof graphs� � ������of posets� ��Ex� �� ���of trees� ���$��
isthmus� see bridge
Jn� ���Jarn')k�s algorithm� ��������Jensen�s inequality� ���Ex� �Jordan curve� ���theorem� ��������
Jordan$Sch&on�ies theorem� ���
KG� ���
Index ��
Kn� � Kn�m� � �kernel� ���Klein bottle� �� Kneser graph� � �Ex� �Kruskal�s algorithm� ��������Kuratowski�s theorem� ��������
Laplace matrix� ���� ���Ex� �largest element� ��Ex� �Latinrectangle� ���Ex� �square� ���$���squares� orthogonal� ���
leaf� see end�vertexleft maximum� �� ������ ���Leibniz formula� ��Ex� ��lemmaErd/os$Szekeres� ���Ex� �Sperner�s� � �������
�� Ex� �lexicographic ordering� ���lineat in�nity� ���of a projective plane�
��������line graph� ���Ex� �linearalgebra application�
���$���� ���$�������Ex� ��� ���$���
extension� ��Ex� ����Ex� ��
mapping� ���ordering� ��span� ��
linearity of expectation���������
linearly dependent set� �� list chromatic number�
� �Ex� ��Littlewood$O�ord problem�
���Ex� �logical formula� ���� ���Ex� �loop� ��
LYM inequality� ���
Mader�s theorem� ���Ex� �maintaining an equivalence�
��������� ���Ex� �map� see functionmap coloring� ���$� �mapping� see functionlinear� ���
Markov inequality� ���Ex� �matching� ���Ex� � mathematical induction� ��matrix� ���diagonal� ���identity� ���incidence� ���� ���Ex� ��
�� � ���Laplace� ���� ���Ex� �multiplication� �� ������ ���checking� ���������
permutation� ���Ex� ��positive de�nite� ���Ex� �rank� ���� ���regular� ���totally unimodular� ���Ex� �transposed� ���
matroid� �� � ���maximal element� ��Ex� �maximum spanning tree�
�� Ex� �maximum� left� �� ������ ���meanarithmetic� ��geometric� ��harmonic� � Ex� �
Menger�s theorem� ���metric� � �� ���Ex� �metric space� � �minimal element� ��Ex� �minimum spanning tree� ���$���minor� �� � � Ex� ��M&obius band� �� monotone function number of�
��Ex� �multigraph� ��
�� Index
multinomialcoe�cient� ��theorem� �������� ����
���Ex� �multiple edges� ��
N� �natural numbers� �neighbor� ��network� ���node of a graph� see vertexnumberBell� ��Ex� �� � �Ex� ��Betti� see cyclomatic numberCatalan� ���$�� chromatic� ��������list� � �Ex� ��
cyclomatic� ���Euler� ��Fibonacci� � �$���harmonic� ��������
��Ex� ��integer� �natural� �perfect� ��Ex� ��rational� �real� �
number ofalkane radicals� ���Ex� ��arrangements� ��ball distributions� ���
��Ex� ��binary rooted trees�
���Ex� ��binary trees� ���$���divisors� ��Ex� ��edges of a planar graph�
��������equivalences� ��Ex� �even sets� ���������functions� �������functions onto� ��Ex� �graphs� ��Ex� ��� � �nonisomorphic� � �
Latin rectangles� ���Ex� �
monotone functions� ��Ex� �one�to�one functions� �������ordered k�tuples� ��Ex� ��partitions of n� ���$���planted trees� ���Ex� ��
���Ex� �solutions� ��� ���spanning trees� see number of
treesfor general graph� ��������
subsets� �������� ����������Ex� ��
odd�size� � ������ ��trees� ���$���nonisomorphic� �� Ex� ��
���Ex� �� ���Ex� �with given score� ��������
triangulations of a polygon���Ex� ��� �� Ex� �
unordered k�tuples� ��Ex� ��
O�� �������o�� ��one�to�one function� �������number of� �������
operation� binary� ���� ���orderof a Latin square� ���of a permutation� ��Ex� �of a projective plane�
��������orderedpair� � set� � $��
ordering� � �����lexicographic� ���linear� ��partial� ��
orientation� ���Ex� �� ���oriented graph� ���orthogonalLatin squares� ���vectors� ���
outdegree� ���outer face� ���
Index ��
outerplanar graph� ���Ex� �
P �� ��������pn� ���Pn� � PX� ��pairordered� � unordered� �
partial fractions� �� partial ordering� ��partitionof n� ���$���ordered� ���� ���Ex� �
Pascal triangle� ��path� � � � �Hamiltonian� ���Ex� �uniqueness� ��������
perfect number� ��Ex� ��period of a function� ���Ex� �permutation� ��$��cycle� ��� ����xed point� ��� ���Ex� ��
� �Ex� ��increasing segment� ��Ex� �inversion� ��Ex� �left maximum� �� ������ ���matrix� ���Ex� ��order� ��Ex� �random� ��� ��� ���������
���� ���� ���sign� ���
Petersen graph� � �Ex� �planar drawing� ��������planar graph� ���$� �maximal� ��������number of edges� ��������score� ��������
planea�ne� ���Ex� � � ����
���Ex� �Fano� ���graph� ���projective� see projective plane
planted tree� ���
Platonic solids� ���pointat in�nity� ���� ���of a projective plane�
��������polynomial� characteristic� ���polytope� regular� ���poset� ��� ���automorphism� ���� ���Ex� �isomorphism� ��Ex� �� ���
positive de�nite matrix����Ex� �
postulate� Bertrand� ��potential� ���Ex� �� ���di�erence� ���
power series� ���$� �� �Ex� ��
power set� ��Prim�s algorithm� see Jarn')k�s
algorithmprime number theorem� �������principle� inclusion$exclusion�
��$��� ���Ex� �applications� ��$��
probability� ��Ex� �� ��� �����Ex� ��� ���$�������$���
space� �nite� ��������space� in�nite� ���
problemfour�color� ���hatcheck lady� ��������
� �Ex� ��recurrence� ��Ex� ��
��Ex� �Littlewood$O�ord� ���Ex� �maximum spanning tree�
�� Ex� �minimum spanning tree�
��������Sylvester�s� �� Ex� �
product� �Cartesian� ��empty� ��scalar� ���
�� Index
projection� stereographic� ���projective planeconstruction� ���$����
���$���duality� ���� ����nite� �� $���de�nition� �� ������
���Ex� �� ���Ex� �����Ex� �
existence� �� $���order� ��������
real� ���� ���property B� ���Pr&ufer code� ���
QUICKSORT� �� $���
R� �R� ���rA� ���radius� ���Ex� �randomgraph� ��������� ���Ex� ��
���Ex� �permutation� ��� ���
��������� ���� �������
variable� ��������walk� ���$���
randomized algorithm� ���randomly Eulerian graph�
���Ex� �rank of a matrix� ���� ���rationals� �real projective plane� ���� ���reals� �rectangle� Latin� ���Ex� �recurrence� ���$���recurrent relation� see recurrencere�exive relation� �������region of a Jordan curve�
��������regulargraph� ���Ex� ��matrix� ���
polytope� ���relation� �������acyclic� ��Ex� �antisymmetric� � composition� ��re�exive� �������symmetric� �������transitive� �������� ��Ex� �
root of a tree� ���row operation� elementary� ���
Sn� ��Sn� ��������scalar product� ���scoreof a graph� ���$���of a planar graph� ��������of a tree� ���Ex� �
search� depth��rst� � �section� golden� ���� ���series� power� ���$� �
� �Ex� ��setconnected� ���dominating� ���Ex� ��empty� ��independent� ���ordered� � $��partially ordered� ��
set system� ��independent� �����colorable� ���� ���$����
���Ex� �sgn�� ���sign of a permutation� ���smallest element� ��Ex� �solid� Platonic� ���son in rooted tree� ���sorting algorithm� ��Ex� ��
�� $���spacemetric� � �of circulations� ���of cuts� ���of cycles� ���������
Index ��
probability�nite� ��������in�nite� ���
vector� ���span� linear� �� spanning forest� ���spanning tree� ���$���algorithm� ���������
��������maximum� �� Ex� �minimum� ���$���
Sperner�s lemma� � ��������� Ex� �
Sperner�s theorem� ��������sphere with handles� �� square matrix� ���square� Latin� ���$���Steiner system� ����������
���������� ���Ex� �Steiner tree� ���Steinitz theorem� ���step� inductive� ��stereographic projection� ���Stirling�s formula� ��strongly connected graph�
��������subdivision of a graph�
��������sub�eld� ���subgraph� � ������induced� � ������
submatrix� ���subsequencedecreasing� ���Ex� �increasing� ���Ex� �
subsetsnumber of� ��������
�������� ��Ex� ��subspace� �� sum� �� ��empty� ��
supA� ��Ex� ��supremum� ��Ex� ��surjection� ��Sylvester�s problem� �� Ex� �
sym�� ���symmetricchain� ���di�erence� ���relation� �������
symmetrization� ���system of sets� ��system� Steiner� ����������
���������� ���Ex� �
T �� ���tactical con�guration� ���theoremBinet$Cauchy� ��������binomial� �������combinatorial meaning� ���generalized� � �� ����� ���
Borsuk$Ulam� � �Brouwer�s� � �������
�� Ex� �de Moivre�s� ��Ex� �� �� Dilworth�s� ���Ex� ��xed point� � �������
� ������Gr&otsch� ���Ex� �Graham$Pollak� ���������Jordan curve� ��������Jordan$Sch&on�ies� ���Kuratowski�s� ��������Mader�s� ���Ex� �Menger�s� ���multinomial� �������� ����
���Ex� �on score� ��������prime number� �������Sperner�s� ��������Steinitz� ���Tur'an�s� ��������� ���Ex� �Wilson�s� ���������
time complexity� ���topological graph� ��������torus� ���totally unimodular matrix�
���Ex� �tough graph� ���Ex� �
�� Index
tour� ���directed� ���Eulerian� ���
tournament� ���Ex� �� ���transitiveclosure� ��Ex� �relation� �������� ��Ex� �
transposed matrix� ���tree� ��������asymmetric� �� Ex� �binary� ���$���code� ���planted� ���rooted� ���spanning� ���$���algorithm� ��������minimum� ���$���
Steiner� ���trees� number of� �� Ex� ��
���$���� ���$�������Ex� �� ���Ex� �����Ex� ��� ���Ex� �
triangle�free graph� ���triangular matrix� ���triangulation� ���� ��������of a polygon� ��Ex� ���
�� Ex� �Tur'an�s theorem� ���������
���Ex� ���coloring� ���� ���$����
���Ex� ���connected graph� ���$���critical� ���Ex� �
unbounded face� ���uniform set system� ���UNION$FIND� ���������
���Ex� �unordered pair� � upper triangular matrix� ���
V G� ��variable� random� ��������variance� ���Ex� �variations� ��
vector space� ���vectors� orthogonal� ���vertex� �������connectivity� ���
walk� � �random� ���$���
weakly connected graph���������
well�ordering� ��Wilson�s theorem� ���������
Z� �