CSE 20 DISCRETE MATH Prof Shachar Lovett http
- Slides: 26
CSE 20 DISCRETE MATH Prof. Shachar Lovett http: //cseweb. ucsd. edu/classes/wi 15/cse 20 -a/ Clicker frequency: CA
Todays topics • Proofs for algorithms: • Euclid’s algorithm • Section 3. 7 in Jenkyns, Stephenson
GCD • GCD = Greatest Common Divisor • GCD(a, b): largest n such that n|a and n|b • One way to compute it: • Factor a, b to prime factors • n = product of common prime factors • No efficient way to do so (since we don’t know how to factor to prime numbers efficiently) • Euclid’s algorithm provides a much faster way
Euclid’s algorithm •
Euclid’s algorithm • (a, b) (b, a mod b)
Euclid’s algorithm •
Euclid’s algorithm • Example run: a=20, b=30 a 20 30 20 10 b 30 20 10 0
Euclid’s algorithm • The same basic questions 1. Does it always terminate? 2. Does it return the correct answer? 3. How fast is it?
Euclid’s algorithm: termination •
Euclid’s algorithm: termination •
Euclid’s algorithm: termination • The value of a keeps decreasing, which proves termination
Euclid’s algorithm: correctness • g=gcd(a, b)
Euclid’s algorithm: correctness •
Euclid’s algorithm: correctness •
Euclid’s algorithm: correctness •
Euclid’s algorithm: correctness •
Euclid’s algorithm: correctness • g=gcd(a, b) Proved!
Euclid’s algorithm: speed • How many iterations?
Euclid’s algorithm: speed •
Euclid’s algorithm: speed •
Euclid’s algorithm: speed •
Euclid’s algorithm: speed •
Extended Euclid’s algorithm •
Extended Euclid’s algorithm •
Extended Euclid’s algorithm •
Next class • Relations • Read section 6. 1 in Jenkyns, Stephenson
- Shachar lovett
- Shachar tauber
- Mmt grading scale
- Sandra hrmn
- Lovett
- Marsha lovett
- What is discrete math
- Inverse error
- Modeling computation discrete math
- Absorption law logic equivalence
- Discrete math problems
- Discrete math propositional logic
- String in maths
- Antisymmetric relation definition
- Discrete math set identities
- Sequence discrete math
- Double implication
- A. 1 b. 2 c. 3 d. 4
- Subtraction rule counting
- What is discrete math
- Nested quantifiers
- Discrete math susanna epp
- Poset discrete math
- Counterexample discrete math
- What is recursion in discrete mathematics
- Resolution example
- Recurrence discrete math