CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA
Todays topics Order relations Section 6.3 in Jenkyns, Stephenson
Order relations
Partial order
Definition: reflexive, transitive, anti-symmetric Equality relation: xRy if x=y Is it a partial order? A. Yes B. No
Partial order
Total order
Lexicographic order
Orders on sequences Which one of the following is the largest one? A. (1,2,5,10) B. (10,5,2,1) C. (5,100,3,3) D. (10,7,100,1000)
Maximal / maximum elements
There could be multiple maximal elements in a set, but the maximal element (if it exists) must be unique Lets prove it
Maximal / maximum elements
Minimal / minimum elements
Maximum/maximal/minimum/minimal
Back to total orders
Sorting Sorting is a basic primitive used by many algorithms Most sorting algorithms are “abstract”, in the sense that they can apply to any partial order Naïve sorting on n elements requires comparing all pairs of elements, which takes ~n 2 comparisons Fast sorting algorithms (for example, quicksort) can do it using only n log n comparisons This can be proven to be tight!
Next class Knights and knaves