CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.

Slides:



Advertisements
Similar presentations
CSE 20 Discrete math Prof. Shachar Lovett
Advertisements

CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
February 19, 2015Applied Discrete Mathematics Week 4: Number Theory 1 The Growth of Functions Question: If f(x) is O(x 2 ), is it also O(x 3 )? Yes. x.
CSE 20 DISCRETE MATH Prof. Shachar Lovett Clicker frequency: CA.
Number Theory and Cryptography
Introduction to Analysis of Algorithms
Congruence class arithmetic. Definitions: a ≡ b mod m iff a mod m = b mod m. a  [b] iff a ≡ b mod m.
Algorithms and Problem Solving-1 Algorithms and Problem Solving.
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.
Integers: Multiplication & Division
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
6 Steps of the Programming Process
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
Mathematics of Cryptography Part I: Modular Arithmetic
COMP 170 L2 Page 1 L05: Inverses and GCDs l Objective: n When does have an inverse? n How to compute the inverse? n Need: Greatest common dividers (GCDs)
Today we will compute examples (of positive integer powers of nonnegative integers) as repeated multiplication. compute=to solve positive integer =whole.
Write and compute expressions with powers.
4-1 6 th grade math Exponents. Objective To write and evaluate exponential expressions Why? To prepare you for higher learning in math and science. To.
Synthetic Division. This method is used to divide polynomials, one of which is a binomial of degree one.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CompSci 102 Discrete Math for Computer Science February 16, 2012 Prof. Rodger.
Definitions Add & Subtract Multiply & Divide ExponentsMixed.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Unit 6 Math Vocab By: Marshall Lockyer. Constant Term A constant term is a term in an equation that does not change Example: a = 6 + b : In this case,
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Problem of the Day  I am thinking of a question and propose 3 possible answers. Exactly one of the following is the solution. Which is it? A. Answer 1.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE373: Data Structures and Algorithms Lecture 3: Math Review; Algorithm Analysis Nicki Dell Spring 2014.
Math 10: Basic Mathematics 1 Important Topics from Math 10 Chapter 1 Whole Numbers Write a word name for a number Add, subtract, multiply and divide whole.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
9/22/15UB Fall 2015 CSE565: S. Upadhyaya Lec 7.1 CSE565: Computer Security Lecture 7 Number Theory Concepts Shambhu Upadhyaya Computer Science & Eng. University.
One step equations Add Subtract Multiply Divide  When we solve an equation, our goal is to isolate our variable by using our inverse operations.  What.
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
Beginning of the Year Math Review Houghton Mifflin ©2005.
Division of decimals (by a whole number) When dividing a decimal by a whole number: Divide as you would for a whole number. There are NO remainders! If.
Operations with Scientific Notation SWBAT multiply and divide numbers in scientific notation.
Definitions Add & Subtract Multiply & Divide ExponentsMixed.
Computer Science I: Understand how to evaluate expressions with DIV and MOD Random Numbers Reading random code Writing random code Odds/evens/…
Discrete Mathematics
CSE 311: Foundations of Computing Fall 2013 Lecture 11: Modular arithmetic and applications.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
2.2 Solving Two- Step Equations. Solving Two Steps Equations 1. Use the Addition or Subtraction Property of Equality to get the term with a variable on.
CSC 212 – Data Structures Lecture 15: Big-Oh Notation.
CS480 Cryptography and Information Security
Chapter 4 With Question/Answer Animations 1. Chapter Motivation Number theory is the part of mathematics devoted to the study of the integers and their.
3 3 x =5 When you see a Multiplication problem, you can use the DIVISION Property of Equality to solve it! Remember – a FRACTION means to divide! CHECK.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett.
Chapter 2: Integers and Mathematical Induction
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Big-O notation.
Students will solve two step equations (12-4).
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett
Accentuate the Negative
Discrete Math for CS CMPSC 360 LECTURE 12 Last time: Stable matching
Short Division by Mary S. Roland.
Dry run Fix Random Numbers
More Maths Programming Guides.
Short Division.
Warm-up: Dry Run DIV / MOD 2nd If Then Program
Math-7 NOTES 1) 3x = 15 2) 4x = 16 Multiplication equations:
Order of Operations  + - X.
Multiplication and Division of Integers
COMPUTING.
Presentation transcript:

CSE 20: Discrete Mathematics for Computer Science Prof. Shachar Lovett

Today’s Topics: 1. Algorithms 2. Division algorithms 2

1. Algorithms Every journey begins with one step 3

Algorithms! Multiply 17 x 142. While you do that, think, how can you tell a computer to do that.

What is an algorithm? A. A step by step process B. Any way of solving complex problems C. Computer code D. Math 5

An algorithm?  Definition: a step-by-step process  Each basic step is simple  Together they can compute very complicated things  What properties do we care about? A. It should have the correct format (“compile”) B. It should always terminate C. It should give the correct answer D. All of the above

Complexity of algorithms  Simplistic model: each basic operation (addition, multiplication, etc) takes unit time  Complexity of an algorithm = number of steps = running time  Depends on the input (it takes longer to multiply large numbers)

Pseudocode  Begin, End delimit list of steps.  Allowed types of steps  Assignment  Repeat -loop  If-Then-Else-End  While -loop  Walkthrough / Trace

2. Division algorithms 9

Notation and terms  n DIV d: integer part of dividing n by d  n MOD d: the remainder  n = (n DIV d) * d + (n MOD d)  Example: 7=2*3+1, so  7 DIV 3 = 2  7 MOD 3 = 1

Notation and terms  We say…  d divides n  d is a factor of n  n is a multiple of d  d|n  To mean n=a*d for some integer a.

Solve the equation For what integer x do we have x DIV 5 = 14 and x MOD 5 = 2 ? A. No integers satisfy these equations at the same time. B. Any multiple of 5 works. C. Any non-multiple of 5 works. D. Only x = 72 works. E. None of the above / more than one of the above.

Solve the equation For what integer x do we have x MOD 5 = 2 ? A. -3 (and others) B. -2 (and others) C. All and only the multiples of 5 D. All and only the non-multiples of 5 E. None of the above / more than one of the above.

Why do we need DIV,MOD? Round robin scheduling, secret sharing, parallel computation…

How to compute DIV,MOD?  Write an algorithm that, given two integers n,d, computes n DIV d and n MOD d  How fast is your algorithm? 15

A DIVMOD algorithm 16

A DIVMOD algorithm 17 Loop invariant: n=d*div+mod

A DIVMOD algorithm 18 How many steps does the algorithm perform (roughly)? A. n B. n+d C. n*d D. n/d E. Other

A faster DIVMOD algorithm? 19