Download presentation
Presentation is loading. Please wait.
Published byΕυδώρα Ζαχαρίου Modified over 5 years ago
1
Derived Variables A derived variable v is simply a function
that associate value with state. Die Hard Example: total amount of water in the two jugs v ::= b + l
2
For GCD, already have variables
Derived Variables For GCD, already have variables x, y.
3
Derived Variables Proof of GCD termination:
Show that variable y is strictly decreasing and natural number valued.
4
Derived Variables Termination follows by least number principle:
y must take a least value, and thus the algorithm is stuck.
5
Strictly Decreasing Variable
16 12 8 4 State
6
Weakly Decreasing Variable
16 12 8 4 State
7
Weakly Decreasing Variable
We used to call weakly decreasing variables “nonincreasing” variables. OK terminology but remember: nondecreasing is NOT EQUAL to “not decreasing.”
8
There are 5 girls and 5 boys
Stable Marriage There are 5 girls and 5 boys 1 A 2 B 3 C 4 D 5 E
9
Stable Marriage Preferences: Boys Girls 1: CBEAD A: 35214
2 : ABECD B : 52143 3 : DCBAE C : 43512 4 : ACDBE D : 12345 5 : ABDEC E : 23415
10
Stable Marriage Preferences: Marry 1 with C: Boys 1: CBEAD 2 : ABECD
3 : DCBAE 4 : ACDBE 5 : ABDEC Marry 1 with C: 1 C
11
Stable Marriage Only 4 boys and 4 girls left. Boys 2 : ABED 3 : DBAE
4 : ADBE 5 : ABDE A B D E
12
Stable Marriage A problem: Rogue couples 1 C 4 B
Girl C likes like boy 4 better Boy 4 like girl C better
13
Stable marriage The mating algorithm – day by day
Morning: boys serenade favorite girls Afternoon: girl rejects all but best Serenader Evening: rejected boys cross off girls
14
Stable marriage Termination condition: stop when no
rejection is possible. The algorithm terminates. Everybody ends up married. The resulting marriages are stable.
15
Infinitely Wide Trees … …
16
Infinitely Wide Trees … …
17
Infinitely Wide Trees
18
Infinitely Wide Trees
19
Tutorial Problem 1
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.