Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices

Slides:



Advertisements
Similar presentations
College of Information Technology & Design
Advertisements

CSE115/ENGR160 Discrete Mathematics 03/15/12
5.1 Number Theory. The study of numbers and their properties. The numbers we use to count are called the Natural Numbers or Counting Numbers.
1 Section 2.4 The Integers and Division. 2 Number Theory Branch of mathematics that includes (among other things): –divisibility –greatest common divisor.
Chapter Primes and Greatest Common Divisors ‒Primes ‒Greatest common divisors and least common multiples 1.
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.
Basic properties of the integers
Chapter 3 Growth of Functions
CSE115/ENGR160 Discrete Mathematics 03/15/11
Chapter II. THE INTEGERS
Discrete Structures Chapter 2 Part B Mathematical Induction
Chapter 1 Introduction Definition of Algorithm An algorithm is a finite sequence of precise instructions for performing a computation or for solving.
The Fundamentals: Algorithms, the Integers & Matrices.
Division in the Integers Theorem 1. If n and m are integers and n>0, then m=qn+r for unique integers q and r with 0
Properties of the Integers: Mathematical Induction
WHOLE NUMBERS; INTEGERS Whole numbers: Z 0,+ = the natural numbers  {0}. Integers:
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
BY MISS FARAH ADIBAH ADNAN IMK
The Integers and Division
Integers Number Theory = Properties of Integers
CSCI 1900 Discrete Structures
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 2): The Fundamentals: Algorithms, the.
1 Properties of Integers Objectives At the end of this unit, students should be able to: State the division algorithm Apply the division algorithm Find.
9/2/2015Discrete Structures1 Let us get into… Number Theory.
CSE 504 Discrete Mathematics & Foundations of Computer Science
3.4/3.5 The Integers and Division/ Primes and Greatest Common Divisors Let each of a and b be integers. We say that a divides b, in symbols a | b, provided.
Chapter 3: The Fundamentals: Algorithms, the Integers, and Matrices
The Integers & Division. a divides b if a is not zero there is a m such that a.m = b “a is a factor of b” “b is a multiple of a” a|b Division.
The Integers. The Division Algorithms A high-school question: Compute 58/17. We can write 58 as 58 = 3 (17) + 7 This forms illustrates the answer: “3.
CompSci 102 Discrete Math for Computer Science
Copyright © Zeph Grunschlag, Basic Number Theory Zeph Grunschlag.
Chapter Algorithms 3.2 The Growth of Functions 3.3 Complexity of Algorithms 3.4 The Integers and Division 3.5 Primes and Greatest Common Divisors.
Chapter 2 (Part 1): The Fundamentals: Algorithms, the Integers & Matrices The Integers and Division (Section 2.4)
Algorithms 1.Notion of an algorithm 2.Properties of an algorithm 3.The GCD algorithm 4.Correctness of the GCD algorithm 5.Termination of the GCD algorithm.
Foundations of Discrete Mathematics Chapter 4 By Dr. Dalia M. Gil, Ph.D.
The Fundamentals. Algorithms What is an algorithm? An algorithm is “a finite set of precise instructions for performing a computation or for solving.
Module #9 – Number Theory 1/5/ Algorithms, The Integers and Matrices.
Application: Algorithms Lecture 20 Section 3.8 Wed, Feb 21, 2007.
Greatest Common Divisors & Least Common Multiples  Definition 4 Let a and b be integers, not both zero. The largest integer d such that d|a and d|b is.
R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 3 Algorithms.
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
Divisibility and Modular Arithmetic
Slide Copyright © 2009 Pearson Education, Inc. 5.1 Number Theory.
AF2. Turn off your phones Primes, gcd, some examples, reading.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Chapter 4 With Question/Answer Animations 1. Chapter Summary Divisibility and Modular Arithmetic - Sec 4.1 – Lecture 16 Integer Representations and Algorithms.
Ch04-Number Theory and Cryptography 1. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic.
Ch03-Algorithms 1. Algorithms What is an algorithm? An algorithm is a finite set of precise instructions for performing a computation or for solving a.
Module #9 – Number Theory 6/11/20161 Chapter 3 Algorithms, Integers and Matrices.
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.
Number Theory Lecture 1 Text book: Discrete Mathematics and its Applications, 7 th Edition.
Discrete Mathematics Chapter 2 The Fundamentals : Algorithms, the Integers, and Matrices. 大葉大學 資訊工程系 黃鈴玲.
Fuw-Yi Yang1 Textbook: Introduction to Cryptography 2nd ed. By J.A. Buchmann Chap 1 Integers Department of Computer Science and Information Engineering,
Chapter 3 The Fundamentals: Algorithms, the integers, and matrices Section 3.4: The integers and division Number theory: the part of mathematics involving.
Agenda Review:  Relation Properties Lecture Content:  Divisor and Prime Number  Binary, Octal, Hexadecimal Review & Exercise.
Number Theory. Introduction to Number Theory Number theory is about integers and their properties. We will start with the basic principles of divisibility,
CS 210 Discrete Mathematics The Integers and Division (Section 3.4)
Integers and Division Section 3.4.
The Growth of Functions
MATH301- DISCRETE MATHEMATICS Copyright © Nahid Sultana Dr. Nahid Sultana Chapter 4: Number Theory and Cryptography.
Applied Discrete Mathematics Week 3: Algorithms
Applied Discrete Mathematics Week 4: Number Theory
Enough Mathematical Appetizers!
Applied Discrete Mathematics Week 6: Computation
The Integers & Division
CMSC 203, Section 0401 Discrete Structures Fall 2004 Matt Gaston
Copyright © Zeph Grunschlag,
Divisibility and Modular Arithmetic
Applied Discrete Mathematics Week 10: Introduction to Counting
Number Theory.
Presentation transcript:

Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices Algorithm: specifying a sequence of steps used to solve a problem. Computational complexity of an algorithm: what are the computer resources needed to use this algorithm to solve a problem of a specified size? Integers: properties of integers, division of integers, algorithms involving integers. Matrices: basic material about matrices, matrix arithmetic.

2.1 Algorithms Definition 1. An algorithm is a finite sequence of precise instructions for performing a computation or for solving a problem. Example 1 Describe an algorithm for finding the maximum (largest) value in a finite sequence of integers. Solution Set the temporary maximum equal to the first integer in the sequence. Compare the next integer in the sequence to the temporary maximum, and set the larger one to be temporary maximum. Repeat the previous step if there are more integers in the sequence. Stop when there are no integers left in the sequence. The temporary maximum at this point is the maximum in the sequence. Instead of using a particular computer language, we use a form of pseudocode.

The properties of algorithms: Input Output Definiteness Correctness Finiteness Effectiveness Generality

Example 2 Describe an algorithm for finding an element x in a list of distinct elements

2.2 Complexity of Algorithms Assume that both algorithms A and B solve the problem P. Which one is better? Time complexity: the time required to solve a problem of a specified size. Space complexity: the computer memory required to solve a problem of a specified size. The time complexity is expressed in terms of the number of operations used by the algorithm. Worst case analysis: the largest number of operations needed to solve the given problem using this algorithm. Average case analysis: the average number of operations used to solve the problem over all inputs.

Example 3 Analyze the time complexities of Algorithm 1 and 2 Number of operations 1 n 2(n-1) 3n-1 1 2(n+1) n 2 3n+5

Number of operations = 4 log n+4 1 2 Number of operations = 4 log n+4 2

For finding x in a list of n elements, we have two algorithms Which use Which one is better? A constant factor does not influence the running time so much. Therefore, 3n+5 grows faster than when n becomes larger. Usually, we say that 3n+5 is O(n) and say that is O( ).

Running time for a problem with size Time necessary operations Orders of Growth Running time for a problem with size Running Time necessary operations Operation Per second instant 1 second 11.5 days Never end days Instant Using silicon computer, no matter how fast CPU will be you can never solve the problem whose running time is exponential !!!

Asymptotic Notations: O-notation Definition 2.1 A function f(n) is said to be O(g(n)) if there exist some constant N

Example 3 Prove 2n+1=O(n) Example 5 List the following function in O-notation in increasing order:

2.2 The Integers and Division We discuss the properties of integers which belongs to the branch of Mathematics called number theory. b is a multiple of a a is a factor of b Example 1 Determine whether 3|7 and whether 3|12. Solution: It follows that 3|7 and 3|12.

Basic properties of divisibility of integers Theorem 1. Let a, b, and c be integers. Then If a|b and a|c, then a|(b+c). If a|b, then a|bc for all integers c. If a|b and b|c, then a|c. Proof There are s and t such that b=as and c=at. Therefore, b+c=a(s+t). There is s such that b=as. Therefore, bc=a(sc) There are s and t such that b=as and c=bt, therefore, c=a(st)

Definition 2. A positive integer p greater than 1 is called prime if the only positive factors of p are 1 and p. A positive integer that is greater than 1 and is not prime is called composite. Example 2. Is 7 a prime? The primes less than 100 are 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89 and 97. Theorem 2. Every positive integer can be written uniquely as the uniquely as the product of primes in order of increasing size.

divisor dividend quotient remainder Example 4 What are the quotient and remainder when 101 is divided by 11? Solution: We have quotient remainder

Definition 3. Let a and b be integers Definition 3. Let a and b be integers. The largest integer d such that d|a and d|b is called the greatest common divisor of a and b, denoted by gcd(a,b). Example 5 What is gcd(24,36) and gcd(17,22)? Definition 4. The integers a and b are relatively prime if gcd(a,b)=1. Definition 5. The least common multiple of the positive integers a and b is the smallest positive integer that is divisible by both a and b, denoted by lcm(a,b).

Definition 6. Let a be an integer and m be a positive integer Definition 6. Let a be an integer and m be a positive integer. We denoted by a mod m the remainder when a is divided by m. Example 7 17 mod 5 = 2, -133 mod 9=2, and 2001 mod 101 = 82.

2.4 Integers and Algorithms The Euclidean Algorithm: Find the greatest common divisor of two positive integers Lemma 1 Let a=bq+r, where a,b,q, and r are integers. Then gcd(a,b)=gcd(b,r).

Example 1 Find the greatest common divisor of 414 and 662 using the Euclidean Algorithm. Solution: Hence, gcd(414,662)=2, since 2 is the last nonzero remainder.

Representation of integers

 Algorithm for integer operations Addition of a and b Example 5 1 1 1 0 1 0 1 1 1 1 0 0 1

Multiplication of a and b 1 1 0 1 0 1 1 0 0 0 1 0 0 0 0 1 0 b a shifts 0 place a shifts 1 place a shifts 3 places

2.6 Matrices j column i row i row j column

Algorithms for matrix multiplication

Transposes and powers of matrices

Zero-One Matrices A matrix with entries that are either 0 or 1 is called a zero-one matrix.

. .