CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.

Slides:



Advertisements
Similar presentations
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Advertisements

CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Prof. Shachar Lovett Clicker frequency: CA CSE 20 Discrete math Prof. Shachar Lovett
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSE 373: Data Structures and Algorithms Lecture 5: Math Review/Asymptotic Analysis III 1.
Pamela Leutwyler. 9 goes into 36 four times with remainder = 9.
Partial Quotients Division Algorithm. Quick Slate Review Solve the following problems. ……. Ready……… …………..Set………….. ………Go!
CSE 20 Discrete math Prof. Shachar Lovett
4-2 6 th grade math Prime Factorization. Objective To use divisibility rules to check for divisibility and write the prime factorization of numbers in.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSC 2300 Data Structures & Algorithms January 30, 2007 Chapter 2. Algorithm Analysis.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Prime Factorization Math.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
(BASIC MATH) QUIZ. START!! Click Here!! 1. What is Addition? a. The act or process of adding numbers. The act or process of adding numbers. b. The act.
Solving Multiplication and Division Equations. EXAMPLE 1 Solving a Multiplication Equation Solve the equation 3x = x = 15 Check 3x = 45 3 (15)
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Mr. Lehman Lehman Laboratories © 2015
division algorithm Before we study divisibility, we must remember the division algorithm. r dividend = (divisor ⋅ quotient) + remainder.
Divisibility Rules How do we know when we can divide one number into another exactly?
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Arithmetic.
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
CSCI 1900 Discrete Structures
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Solving Equations Medina1 with Multiplication and Division.
DIVISIBILITY RULES.
Divisibility Test For Different Numbers
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
More on Efficiency Issues. Greatest Common Divisor given two numbers n and m find their greatest common divisor possible approach –find the common primes.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Complexity Analysis: Asymptotic Analysis. Recall What is the measurement of algorithm? How to compare two algorithms? Definition of Asymptotic Notation.
Factors, Prime Numbers & Composite Numbers. Definition Product – An answer to a multiplication problem. 7 x 8 = 56 Product.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Division by 2 Any number that ends is 0, 2, 4, 6, or 8 is evenly divisible by 2.
Multiply By 2-Digit Numbers (B) Unit 2 Lesson 6. Objectives:
DIVISIBILITY RULES. A number is divisible by: If the number ends in 0 the number is also divisible by 2 and 3 the sum of the number's digits.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Factors, Prime Numbers & Composite Numbers
Polynomial Division.
Math & Exponents.
Solving Two- Step Equations
RAPID Math.
PEA202 – Lecture #1 NUMBER SYSTEM.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
MATH 15A – Discrete Mathematics
Solving Two- Step Equations
Multiplication and Division
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
Factors, Prime Numbers & Composite Numbers
Divisibility Rules.
Multiplying and dividing recap
Factors, Prime Numbers & Composite Numbers
Divisibility Rules.
Multiplication and Division Property of Radicals
PRIME FACTORIZATION USING FACTOR TREES!.
Section 4.1 Divisibility and Factors
1. Integers and Decimals.
Presentation transcript:

CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA

Todays topics Proofs for algorithms Casting out nines Fast exponentiation Section 3.7 in Jenkyns, Stephenson

Casting out nines Goal: check if a number n is divisible by 9 Algorithm: Keep summing the digits (in base 10) Until we get a 1-digit number Which is easy to check Questions: Does the algorithm terminate? Does it return the correct answer? How fast?

Casting out nines

Casting out nines: termination

Casting out nines: correctness

Casting out nines: speed

Fast exponentiation

Questions: Does the algorithm terminate? Does it return the correct answer? How fast? Termination is simple: dividing b by 2 at each step (and rounding down), guarantees that eventually b=0 We will analyze correctness and speed

Fast exponentiation: correctness Let a*,b* denote original inputs

Fast exponentiation: correctness

Fast exponentiation: speed Question 3: how fast is the algorithm? Each iteration takes constant time How many iterations? A. a B. b C. log(b) D. log*(b) E. Other

Fast exponentiation: speed Question 3: how fast is the algorithm? Each iteration takes constant time How many iterations? A. a B. b C. log(b) D. log*(b) E. Other

Fast exponentiation: speed Algorithm to compute a b requires ~log(b) operations Compare to naïve algorithm, which multiplies a with itself b times, and requires b operations Example: compute Naïve: 1000 multiplications Fast: ~10 multiplications Fast exponentiation is indeed much faster, and hence is used widely in practice

Fast exponentiation: extensions

Next class More proofs for algorithms: Euclid’s algorithm Read section 3.7 in Jenkyns, Stephenson