Basic Concepts of Linear Order

Combinatorics for Computer Science (Unit 1)

S. Gill Williamson ©S. Gill Williamson 2012 Preface

From 1970 to 1990 I ran a graduate seminar on algebraic and algorithmic com- binatorics in the Department of Mathematics, UCSD. From 1972 to 1990 al- gorithmic combinatorics became the principal topic. The seminar notes from 1970 to 1985 were combined and published as a book, Combinatorics for Com- puter Science (CCS), published by Computer Science Press. Each of the "units of study" from the seminar became a chapter in this book. My general goal is to re-create the original presentation of these (largely inde- pendent) units in a form that is convenient for individual selection and study. Here, we isolate Unit 1, corresponding to Chapter 1 of CCS, and reconstruct the original very helpful unit specific index associated with this unit. Theorems, figures, examples, etc., are numbered sequentially: EXERCISE 1.38 and FIGURE 1.62 refer to numbered items 38 and 62 of Unit 1 (or Chap- ter 1 in CCS), etc. CCS contains an extensive bibliography for work prior to 1985. For further references and ongoing research, search the Web, particularly Wikipedia and the mathematics arXiv (arXiv.org). These notes focus on the visualization of algorithms through the use of graph- ical and pictorial methods. This approach is both fun and powerful, preparing you to invent your own algorithms for a wide range of problems. S. Gill Williamson, 2012 http : \www.cse.ucsd.edu\ ∼ gill

iii iv Table of Contents for Unit 1

Descriptive tools from set theory...... 3 relations, equivalence relations, set partitions, image, coimage surjection, injection, , covering relations, Hasse diagrams, exercises and ex- amples. Basic data structures ...... 7 exercises, examples, order preserving , hashing tables, linked lists, structural diagrams. Lexicographic order ...... 14 colex order, examples lex and colex order, permutations in lex order, in- creasing functions in lex and colex order, Hasse diagrams of products of lex orders, lex bucket sort, diagrams for prelex, inlex, postlex orders, length-first lex, tilings of board in lex order, backtracking, 5-queens prob- lem, isomorph rejection, minimal representatitives, soma cube in lex order, dominoe coverings in lex order, examples of isomorph rejection. Ordered partition trees ...... 24 partition trees, local descriptions, partition trees and lex order, partition trees for functions, permutations in direct insertion order, lex order bijec- tions for permutations, partition trees for decreasing functions, binomial coefficients, tree reduction, order for posets, RANK and UN- RANK algorithms. Examples ...... 37 n-queens problem, orbit refinement, initial and terminal segments of lists. Subject Index ...... 47

1 2 UNIT 1

3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 Index

antisymmetric,3 linked list,9 direct access model,9 backtracking direct insertion order tilings, 19 permutations, 28 bucket sort, 15, 16 coded version, 29 card sort, 15, 16 edge labels, 29 cardinality,3 domino covering characteristic function,7 isomorph rejection, 23 chessboard lex minimal sdr, 23 4-queens equivalence orbit refinement, 39 class,4 partition tree, 40 class partition,4 8-queens discussion, 36, 37 n-queens definition,3 not symmetry recursive, 41 examples,5 search on (n∪{∗})n, 41 general discussion of, 43 function keys of solution sets, 38 coimage partition,5 orbits domain,4 linear order, 37 image,4 of positions, 37 injection,5 symmetries of, 37 inverse image,4 symmetry recursive one-line notation,5 examples, 44–46 range,4 A Coimage f ∈ B surjection,5 −1 {f (b) | b ∈ B},5 functions colex order {f | f : A → B} = BA, colexicographic order, 14 4 recursive definition, 15 colexicographic order graph theory functions, 14 equivalence relations,5 contents,1 covering relation,6 hashing table,8 Hasse diagram data structure defined,6

47 examples,7 products of, 15 specified in practice,8 A Image f ∈ B linked list {f(a) | a ∈ A},4 doubly linked, 11, 12 integers example,9 bucket notation of linked lists, 12, 13 n = {0, . . . , n−1}, 32 pointers, 10 divisibility order,6 structural diagram, 10 positive,4,6 underline notation order , 29 {1, . . . , n} = n,4 Sn lex to direct insertion, 30 isomorph rejection poset, 32 cube, 23 predecessor, 30 domino covering, 23 RANK and UNRANK, 32 hexagon, 23 successor, 30 orderly algorithms, 42 order preserving bijection,7 symmetry recursive, 42 ordered partition system of representatives, 42 and words, 23 tetrahedron, 23 defined, 23 refinement, 23 lex order tree, 24 inlex, 18 ordered sets length-first, 18 examples,6 lexicographic order, 14 permutations, 27 partial order postlex, 18 poset,6 prelex, 18 partition lexicographic order block,4 bucket sort, 15, 16 discrete,4 card sort, 15 equivalence relation,4 functions, 14 ordered defined, 23 injective functions, 14 ordered refinement, 23 nondecreasing functions, 14 refinement order,6 one-to-one set,4,6 functions, 14 partition tree prelex order, 16 binary, 26 product sets, 15 complete binary, 26 recursive definition, 15 contraction of (1.42, 1.44), 26 terminal symbols, 16 example, 23 linear order,3 lex order, 25 as ordered partitions, 23 local description, 25 defined,8 permutations direct insertion, lexicographic, 14 28

48 permutations lex order, 27 terminal vertices - leaves, 24 permutations vertices, 24 direct insertion order, 28 tree diagram lex order, 27 D(64) decreasing, 31 random selection, 35 D(nk) decreasing, 30 poset S3 direct insertion, 28, 29 covering relation,6 S3 lex order, 27 order isomorphism defined, 32 23 lex order, 26 preface, iii rd local lex order, 25 prelex order general partition, 24 tree diagram, 17 words RANK and UNRANK 5-queens decreasing functions, 34, 35 lex minimal sdr, 21 defined, 32 problem defined, 20 general disussion, 36 symmetries, 21 random selection, 35 backtracking, 19 recursion domino coverings for D(nk), 31 all 4 × 4, 21, 22 reflexive,3 prelex coding, 21 relations inherited orders, 18 antisymmetric,3 length ≤ d, 18 covering,6 length-first lex (colex), 18 equivalence,3 postlex order, 18 linear,3 prelex order, 18 on matrices,7 SOMA cube, 21 order,3,6 terminal symbol ∗, 18 product,7 tiling orders, 19 reflexive,3 symmetric,3 transitive,3 transitive closure 1.13(5),7 residual tree R(e) of edge, 32 general examples, 33 set partition,4 transitive,3 tree ordered rooted, 24 partition, 24, 26–31 residual, 32

49 NOTES

50 NOTES

51 NOTES

52 NOTES

53