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
- Lovett scale muscle strength
- Sandra hrmn
- Lovett
- How learning works
- Discrete mathematics
- Inverse error
- Eecs 1019
- What is tautology in math
- Contoh matematika diskrit
- Discrete math propositional logic
- String in maths
- Example for reflexive relation
- Discrete identity
- Sets and functions in discrete mathematics
- In triangle pqr
- What does onto mean in discrete math
- Product rule discrete math
- Euler circuit
- Nested quantifiers
- A computer programming team has 13 members
- Poset discrete math
- Counterexample discrete math
- Recursive definition in discrete mathematics
- Math resolution
- Recurrence discrete math