diff --git a/assets/people/oliver-square.jpg b/assets/people/oliver-square.jpg
new file mode 100644
index 00000000..cda08067
Binary files /dev/null and b/assets/people/oliver-square.jpg differ
diff --git a/src/teaching/cse-250/2022fa/index.erb b/src/teaching/cse-250/2022fa/index.erb
index 91a0a059..990ae023 100644
--- a/src/teaching/cse-250/2022fa/index.erb
+++ b/src/teaching/cse-250/2022fa/index.erb
@@ -347,6 +347,8 @@ schedule:
- date: 10/14/22
topic: Order Relations, Priority Queues
dow: Fri
+ section_b:
+ slides: slide/19b-Orderings.html
- week: 8
lectures:
- date: 10/17/22
diff --git a/src/teaching/cse-250/2022fa/slide/16b-GraphExploration.erb b/src/teaching/cse-250/2022fa/slide/16b-GraphExploration.erb
index 98ac5705..68e0373a 100644
--- a/src/teaching/cse-250/2022fa/slide/16b-GraphExploration.erb
+++ b/src/teaching/cse-250/2022fa/slide/16b-GraphExploration.erb
@@ -480,7 +480,7 @@ def DFSOne(graph: Graph[…], v: Graph[…]#Vertex)
$ = O(\sum_{v \in V} deg(v))$
- $ = O(\frac{1}{2} |E|)$ (by rule)
+ $ = O(2 |E|)$ (by rule)
$ = O(|E|)$
diff --git a/src/teaching/cse-250/2022fa/slide/19b-Orderings.erb b/src/teaching/cse-250/2022fa/slide/19b-Orderings.erb
new file mode 100644
index 00000000..f101e928
--- /dev/null
+++ b/src/teaching/cse-250/2022fa/slide/19b-Orderings.erb
@@ -0,0 +1,570 @@
+---
+template: templates/cse250_2022_slides.erb
+title: Graph Exploration
+date: Oct 14, 2022
+textbookTBD: Ch. 15.3
+cat: graphics/19b/cat.png
+---
+
+
+ Examples
+
+
+ - $(B, 10)$, $(D, 3)$, $(E, 40)$
+ - “A+”, “C”, “B-”
+ - Taco Tuesday, Fish Friday, Meatless Monday
+ - The Princess Bride, Crouching Tiger Hidden Dragon, Rob Roy
+ - Aardvark, Baboon, Capybara, Donkey, Echidna, ...
+
+
+
+
+ Ordering
+
+ An ordering $(A, \leq)$ (an ordering over type $A$) is ...
+
+
+ - A collection (set) of things of type $A$
+ - A "relation" or comparator $\leq$ that relates two things
+
+
+
+
+
+
+
- $5 \leq 30 \leq 999$
+ - Numerical order
+
+
+
+
$(E, 40) \leq (B, 10) \leq (D, 3)$
+ Reverse-numerical order on the 2nd field
+
+
+
+
$C+ \leq B- \leq B \leq B+ \leq A- \leq A$
+ Letter grades
+
+
+
+
$AA \leq AM \leq BZ \leq CA \leq CD$
+ Compare 1st letter, if same compare 2nd, if same compare 3rd, ... ("Lexical Order")
+
+
+
+
+
+ Ordering Properties
+
+
+
+
- Crouching Tiger Hidden Dragon $\leq$ Princess Bride
+ - Carey Elwes and Mandy Patankin have amazing banter
+
+
+
+
- Princess Bride $\leq$ Rob Roy
+ - Rob Roy: Best climactic duel of all time
+
+
+
+
- Rob Roy $\leq$ Crouching Tiger Hidden Dragon
+ - A ton of amazingly technical fights
+
+
+
+
+
+ Ordering Properties
+
+
+
+
+ Ordering Properties
+ An ordering needs to be...
+
+ - Reflexive
+ - $x \leq x$
+
+ - Antisymmetric
+ - If $x \leq y$ and $y \leq x$ then $x = y$
+
+ - Transitive
+ - If $x \leq y$ and $y \leq z$ then $x \leq z$
+
+
+
+
+ Ordering Properties
+
+ Course 1 $\leq$ Course 2 iff Course 1 is a prereq of Course 2
+
+ - CSE 115 $\leq$ CSE 116
+ - CSE 116 $\leq$ CSE 250
+ - CSE 115 $\leq$ CSE 191
+ - CSE 191 $\leq$ CSE 250
+
+
+
+
+ Ordering Properties
+
+
+
+
+
+ Is this a valid ordering?
+
+ Yes!
+
+ (Partial order, as opposed to Total order)
+
+
+
+ (Partial)Ordering Properties
+ A partial ordering needs to be...
+
+ - Reflexive
+ - $x \leq x$
+
+ - Antisymmetric
+ - If $x \leq y$ and $y \leq x$ then $x = y$
+
+ - Transitive
+ - If $x \leq y$ and $y \leq z$ then $x \leq z$
+
+
+
+
+ (Total)Ordering Properties
+ A total ordering needs to be...
+
+ - Reflexive
+ - $x \leq x$
+
+ - Antisymmetric
+ - If $x \leq y$ and $y \leq x$ then $x = y$
+
+ - Transitive
+ - If $x \leq y$ and $y \leq z$ then $x \leq z$
+
+ - Complete
+ - Either $x \leq y$ or $y \leq x$ for any $x, y \in A$.
+
+
+
+
+ Formally...
+
+ For a sort order $(A, \leq)$
+
+
+ - Greatest
+ - An element $x \in A$ s.t. there is no $y \in A$, where $x \leq y$
+
+ - Least
+ - An element $x \in A$ s.t. there is no $y \in A$, where $y \leq x$
+
+
+ A partial order may not have a unique greatest/least element
+
+
+
+ Formally...
+
+ $\leq$ can be described explicitly, by a set of tuples.
+
+ $$\{\; (a, a), (a, b), (a, c), \ldots, (b, b), \ldots, (z, z) \;\}$$
+
+ If $(x, y)$ is in the set, $x \leq y$
+
+
+
+ Formally...
+
+ $\leq$ can be described by a mathematical rule.
+
+ $$\{\; (x, y) \;|\; x, y \in \mathbb Z, \exists a \in \mathbb Z_0^{+} : x + a = y \;\}$$
+
+ $x \leq y$ iff $x, y$ are integers, and there is a non-negative integer $a$ s.t. $x + a = y$
+
+
+
+ Formally...
+
+ Multiple orderings can be defined for the same set.
+
+ - RottenTomatoes vs Metacritic vs Box Office Gross.
+ - "Best Movie" first vs "Worst Movie" first.
+ - Rank by number of air ducts crawled through.
+
+
+ We use a subscripts to separate orderings (e.g., $\leq_1$, $\leq_2$, $\leq_3$)
+
+
+
+ Formally...
+
+ We can transform orderings.
+
+ Reverse: If $x \leq_1 y$, then define $y \leq_r x$
+
+ Lexical: Given $\leq_1, \leq_2, \leq_3, \ldots$
+
+ - If $x \leq_1 y$ then $x \leq_\ell y$
+ - If $x =_1 y$ and $x \leq_2 y$ then $x \leq_\ell y$
+ - If $x =_2 y$ and $x \leq_3 y$ then $x \leq_\ell y$
+ - ....
+
+
+
+
+
+ Examples of Lexical Ordering
+
+
+ - Names: First letter, then second, then third...
+ - Movies: Average of reviews, then number of reviews...
+ - Tuples: First field, then second field, then third...
+
+
+
+
+ Formally...
+
+ $\leq$ can be described an ordering over a key derived from the element.
+
+ $x \leq_{edge} y$ iff $weight(x) \leq weight(y)$
+ $x \leq_{student} y$ iff $name(x) \leq_{lex} name(y)$
+
+ We say that the weight (resp., name) is a key.
+
+
+
+ Topological Sort
+
+ A Topological Sort $(A, \leq_2)$ is any total order over $x$ that "agrees" with a partial order $(A, \leq_1)$
+
+ For any two elements $x, y \in X$:
+
+ - If $x \leq_1 y$ then $x \leq_2 y$
+ - If $y \leq_1 x$ then $y \leq_2 x$
+ - Otherwise, either $x \leq_2 y$ or $y \leq_2 x$
+
+
+
+
+
+ Topological Sort
+
+ The following are all topological sorts over our partial order example:
+
+ - CSE 115, CSE 116, CSE 191, CSE 241, CSE 250
+ - CSE 241, CSE 115, CSE 116, CSE 191, CSE 250
+ - CSE 115, CSE 191, CSE 116, CSE 250, CSE 241
+
+
+ (If the partial order is a schedule requirement, each topological sort is a possible schedule)
+
+
+
+ And now, for an ordering-based ADT...
+
+
+
+
+
+ PriorityQueue[A <: Ordering]
+
+
+ - enqueue(v: A): Unit
+ - Insert a value $v$ into the priority queue.
+
+ - dequeue: A
+ - Remove the greatest element in the priority queue.
+
+ - head: A
+ - Peek at the greatest element in the priority queue.
+
+
+
+
+
+ - enqueue(5)
+ - enqueue(9)
+ - enqueue(2)
+ - enqueue(7)
+ - head → 9
+ - dequeue → 9
+ - size → 3
+ - head → 7
+ - dequeue → 7
+ - dequeue → 5
+ - dequeue → 2
+ - isEmpty → true
+
+
+
How do we store these items?
+
5, 9, 2, 7?
+
9, 7, 5, 2?
+
2, 5, 7, 9?
+
+
+
+
+ Two mentalities...
+
+
+ - Lazy: Keep everything in a mess
+ - "Selection Sort"
+ - Proactive: Keep everything organized
+ - "Insertion Sort"
+
+
+
+
+ Lazy Priority Queue
+
+ Base Data Structure: Linked List
+
+
+ - enqueue(t:A)
+ - Append $t$ to the end of the linked list. $O(1)$
+
+ - head/dequeue
+ - Traverse the list to find the largest value. $O(n)$
+
+
+
+
+ Sort
+
+
+ def pqueueSort[A](items: Seq[A], pqueue: PriorityQueue[A]): Seq[A] =
+ {
+ val out = new Array[A](items.size)
+ for(item <- items){ pqueue.enqueue(item) }
+ i = out.size - 1
+ while(!pqueue.isEmpty) { buffer(i) = pqueue.dequeue; i-- }
+ return out.toSeq
+ }
+
+
+
+
+ Selection Sort
+
+
+
+ |
+ Seq/Buffer |
+ PQueue |
+
+
+ Input |
+ (7, 4, 8, 2, 5, 3, 9) |
+ () |
+
+
+ Step 1 |
+ (4, 8, 2, 5, 3, 9) |
+ (7) |
+
+
+ Step 2 |
+ (8, 2, 5, 3, 9) |
+ (7, 4) |
+
+
+ ፧ ፧ ፧ |
+
+
+ Step N |
+ [_, _, _, _, _, _, _] |
+ (7, 4, 8, 2, 5, 3, 9) |
+
+
+ Step N+1 |
+ [_, _, _, _, _, _, 9] |
+ (7, 4, 8, 2, 5, 3) |
+
+
+ Step N+2 |
+ [_, _, _, _, _, 8, 9] |
+ (7, 4, 2, 5, 3) |
+
+
+ Step N+3 |
+ [_, _, _, _, 7, 8, 9] |
+ (4, 2, 5, 3) |
+
+
+ Step N+4 |
+ [_, _, _, 5, 7, 8, 9] |
+ (4, 2, 3) |
+
+
+ Step N+5 |
+ [_, _, 4, 5, 7, 8, 9] |
+ (2, 3) |
+
+
+ Step N+6 |
+ [_, 3, 4, 5, 7, 8, 9] |
+ (2) |
+
+
+ Step 2N |
+ [2, 3, 4, 5, 7, 8, 9] |
+ () |
+
+
+
+
+ Selection Sort
+
+
+ def pqueueSort[A](items: Seq[A], pqueue: PriorityQueue[A]): Seq[A] =
+ {
+ val out = new Array[A](items.size)
+ for(item <- items){ pqueue.enqueue(item) }
+ i = out.size - 1
+ while(!pqueue.isEmpty) { buffer(i) = pqueue.dequeue; i-- }
+ return out.toSeq
+ }
+
+
+ What's the complexity?
+
+
+
+ Proactive Priority Queue
+
+ Base Data Structure: Linked List
+
+
+ - enqueue(t:A)
+ - Find $t$'s position in reverse sorted order. $O(n)$
+
+ - head/dequeue
+ - Refer to the head item in the list. $O(1)$
+
+
+
+
+ Insertion Sort
+
+
+
+ |
+ Seq/Buffer |
+ PQueue |
+
+
+ Input |
+ (7, 4, 8, 2, 5, 3, 9) |
+ () |
+
+
+ Step 1 |
+ (4, 8, 2, 5, 3, 9) |
+ (7) |
+
+
+ Step 2 |
+ (8, 2, 5, 3, 9) |
+ (7, 4) |
+
+
+ Step 3 |
+ (2, 5, 3, 9) |
+ (8, 7, 4) |
+
+
+ Step 4 |
+ (5, 3, 9) |
+ (8, 7, 4, 2) |
+
+
+ Step 5 |
+ (3, 9) |
+ (8, 7, 5, 4, 2) |
+
+
+ Step 6 |
+ (9) |
+ (8, 7, 5, 4, 3, 2) |
+
+
+ Step N |
+ [_, _, _, _, _, _, _] |
+ (9, 8, 7, 5, 4, 3, 2) |
+
+
+ Step N+1 |
+ [_, _, _, _, _, _, 9] |
+ (8, 7, 5, 4, 3, 2) |
+
+
+ ፧ ፧ ፧ |
+
+
+ Step 2N |
+ [2, 3, 4, 5, 7, 8, 9] |
+ () |
+
+
+
+
+
+ Insertion Sort
+
+
+ def pqueueSort[A](items: Seq[A], pqueue: PriorityQueue[A]): Seq[A] =
+ {
+ val out = new Array[A](items.size)
+ for(item <- items){ pqueue.enqueue(item) }
+ i = out.size - 1
+ while(!pqueue.isEmpty) { buffer(i) = pqueue.dequeue; i-- }
+ return out.toSeq
+ }
+
+
+ What's the complexity?
+
+
+
+ Priority Queues
+
+
+
+ Operation |
+ Lazy |
+ Proactive |
+
+
+
+ enqueue |
+ $O(1)$ |
+ $O(n)$ |
+
+
+
+ dequeue |
+ $O(n)$ |
+ $O(1)$ |
+
+
+
+ head |
+ $O(n)$ |
+ $O(1)$ |
+
+
+
+ Can we do better?
+
\ No newline at end of file
diff --git a/src/teaching/cse-250/2022fa/slide/graphics/19b/cat.png b/src/teaching/cse-250/2022fa/slide/graphics/19b/cat.png
new file mode 100644
index 00000000..7a504d25
Binary files /dev/null and b/src/teaching/cse-250/2022fa/slide/graphics/19b/cat.png differ
diff --git a/src/teaching/cse-250/2022fa/slide/graphics/19b/crouchingtigerhiddendragon.png b/src/teaching/cse-250/2022fa/slide/graphics/19b/crouchingtigerhiddendragon.png
new file mode 100644
index 00000000..f8cd3988
Binary files /dev/null and b/src/teaching/cse-250/2022fa/slide/graphics/19b/crouchingtigerhiddendragon.png differ
diff --git a/src/teaching/cse-250/2022fa/slide/graphics/19b/films-not-transitive.svg b/src/teaching/cse-250/2022fa/slide/graphics/19b/films-not-transitive.svg
new file mode 100644
index 00000000..618a1246
--- /dev/null
+++ b/src/teaching/cse-250/2022fa/slide/graphics/19b/films-not-transitive.svg
@@ -0,0 +1,4868 @@
+
+
+
+
diff --git a/src/teaching/cse-250/2022fa/slide/graphics/19b/heap.svg b/src/teaching/cse-250/2022fa/slide/graphics/19b/heap.svg
new file mode 100644
index 00000000..eff8b9d1
--- /dev/null
+++ b/src/teaching/cse-250/2022fa/slide/graphics/19b/heap.svg
@@ -0,0 +1,245 @@
+
+
+
+
diff --git a/src/teaching/cse-250/2022fa/slide/graphics/19b/partial-order.svg b/src/teaching/cse-250/2022fa/slide/graphics/19b/partial-order.svg
new file mode 100644
index 00000000..8df4002a
--- /dev/null
+++ b/src/teaching/cse-250/2022fa/slide/graphics/19b/partial-order.svg
@@ -0,0 +1,148 @@
+
+
+
+
diff --git a/src/teaching/cse-250/2022fa/slide/graphics/19b/princessbride.png b/src/teaching/cse-250/2022fa/slide/graphics/19b/princessbride.png
new file mode 100644
index 00000000..2b972c76
Binary files /dev/null and b/src/teaching/cse-250/2022fa/slide/graphics/19b/princessbride.png differ
diff --git a/src/teaching/cse-250/2022fa/slide/graphics/19b/robroy.png b/src/teaching/cse-250/2022fa/slide/graphics/19b/robroy.png
new file mode 100644
index 00000000..fb5600c7
Binary files /dev/null and b/src/teaching/cse-250/2022fa/slide/graphics/19b/robroy.png differ