R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 3 Algorithms.

Slides:



Advertisements
Similar presentations
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.
Advertisements

22C:19 Discrete Math Integers and Modular Arithmetic Fall 2010 Sukumar Ghosh.
6/20/2015 5:05 AMNumerical Algorithms1 x x1x
Recursion CS-240/CS341. What is recursion? a function calls itself –direct recursion a function calls its invoker –indirect recursion f f1 f2.
Discrete Mathematics Recursion and Sequences
Theory I Algorithm Design and Analysis (9 – Randomized algorithms) Prof. Dr. Th. Ottmann.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
Codes, Ciphers, and Cryptography-RSA Encryption
Fall 2002CMSC Discrete Structures1 Let us get into… Number Theory.
DATA STRUCTURES AND ALGORITHMS Lecture Notes 1 Prepared by İnanç TAHRALI.
February 17, 2015Applied Discrete Mathematics Week 3: Algorithms 1 Double Summations Table 2 in 4 th Edition: Section th Edition: Section th.
Introduction Dr. Ying Lu RAIK 283: Data Structures & Algorithms.
Algorithm analysis and design Introduction to Algorithms week1
CSCI 1900 Discrete Structures
Chapter 2 The Fundamentals: Algorithms, the Integers, and Matrices
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 3 (Part 3): The Fundamentals: Algorithms, the.
February 24, 2015Applied Discrete Mathematics Week 4: Number Theory 1 Modular Arithmetic Let a be an integer and m be a positive integer. We denote by.
Lecture 2 We have given O(n 3 ), O(n 2 ), O(nlogn) algorithms for the max sub-range problem. This time, a linear time algorithm! The idea is as follows:
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 23 Algorithm Efficiency.
MATH 224 – Discrete Mathematics
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 19 Recursion.
C. – C. Yao Data Structure. C. – C. Yao Chap 1 Basic Concepts.
Discrete Mathematics Algorithms. Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are.
1 R. Johnsonbaugh, Discrete Mathematics Chapter 4 Algorithms.
2.3 Functions A function is an assignment of each element of one set to a specific element of some other set. Synonymous terms: function, assignment, map.
DISCRETE MATHEMATICS I CHAPTER 11 Dr. Adam Anthony Spring 2011 Some material adapted from lecture notes provided by Dr. Chungsim Han and Dr. Sam Lomonaco.
Extended Euclidean Algorithm Presented by Lidia Abrams Anne Cheng.
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Recursive. 2 Recursive Definitions In a recursive definition, an object is defined in terms of itself. We can recursively define sequences, functions.
Copyright © Cengage Learning. All rights reserved. CHAPTER 4 ELEMENTARY NUMBER THEORY AND METHODS OF PROOF.
Analyzing algorithms & Asymptotic Notation BIO/CS 471 – Algorithms for Bioinformatics.
Introduction to Algorithms Second Edition by Cormen, Leiserson, Rivest & Stein Chapter 31.
Introduction to Cryptography
Modular Arithmetic with Applications to Cryptography Lecture 47 Section 10.4 Wed, Apr 13, 2005.
The RSA Algorithm. Content Review of Encryption RSA An RSA example.
Fall 2002CMSC Discrete Structures1 Enough Mathematical Appetizers! Let us look at something more interesting: Algorithms.
Algorithm Analysis CS 400/600 – Data Structures. Algorithm Analysis2 Abstract Data Types Abstract Data Type (ADT): a definition for a data type solely.
Algorithm Analysis Data Structures and Algorithms (60-254)
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.
UNIT-I INTRODUCTION ANALYSIS AND DESIGN OF ALGORITHMS CHAPTER 1:
Algorithm Analysis Part of slides are borrowed from UST.
CS Modular Division and RSA1 RSA Public Key Encryption To do RSA we need fast Modular Exponentiation and Primality generation which we have shown.
Prof. Amr Goneid, AUC1 Analysis & Design of Algorithms (CSCE 321) Prof. Amr Goneid Department of Computer Science, AUC Part 1. Complexity Bounds.
CS404 Design and Analysis of Algorithms BBy DDr. M V S Peri Sastry BB.E, PhD(BITS-Pilani)
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: Algorithms,
Application: Algorithms Lecture 19 Section 3.8 Tue, Feb 20, 2007.
JAVA: An Introduction to Problem Solving & Programming, 7 th Ed. By Walter Savitch ISBN © 2015 Pearson Education, Inc., Upper Saddle River,
1 Chapter 2 Algorithm Analysis Reading: Chapter 2.
1 Discrete Structures – CNS2300 Text Discrete Mathematics and Its Applications Kenneth H. Rosen (5 th Edition) Chapter 2 The Fundamentals: 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.
LECTURE 2 : fundamentals of analysis of algorithm efficiency Introduction to design and analysis algorithm 1.
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. 大葉大學 資訊工程系 黃鈴玲.
5.1 Divisors( 약수 ) Definition 5.1.1Definition –n 과 d 가 정수이고 d  0 일 때, n=dq 를 만족시키는 정수 q 가 존재하 면 d 가 n 을 나눈다 (divide) 라고 정의 q 를 몫 (quotient) 이라 하고,
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,
Number-Theoretic Algorithms
Recursion The programs discussed so far have been structured as functions that invoke one another in a disciplined manner For some problems it is useful.
Courtsey & Copyright: DESIGN AND ANALYSIS OF ALGORITHMS Courtsey & Copyright:
Mathematical Induction Recursion
Enough Mathematical Appetizers!
Applied Discrete Mathematics Week 6: Computation
Applied Discrete Mathematics Week 9: Integer Properties
Application: Algorithms
Application: Algorithms
Discrete Mathematics 7th edition, 2009
Introduction to Algorithms
Number Theory.
Recursion.
Presentation transcript:

R. Johnsonbaugh, Discrete Mathematics 5 th edition, 2001 Chapter 3 Algorithms

3.1 Introduction  An algorithm is a finite set of instructions with the following characteristics:  Precision: steps are precisely stated  Uniqueness: Results of each step of execution are uniquely defined. They depend only on inputs and results of preceding steps  Finiteness: the algorithm stops after finitely many steps

More characteristics of algorithms  Input: the algorithm receives input  Output: the algorithm produces output  Generality: the algorithm applies to various sets of inputs

Example: a simple algorithm Algorithm to find the largest of three numbers a, b, c: Assignment operator s := k means “copy the value of k into s”  1. x:= a  2. If b > x then x:= b  3. If c > x then x:= c A trace is a check of the algorithm for specific values of a, b and c

3.2 Notation for algorithms Pseudocode: Instructions given in a generic language similar to a computer language such as C++ or Pascal. Procedure If-then, action If-then-else begin Else Return While loop For loop End

3.3 The euclidean algorithm Divisors:  Given an integer n, we say that k is a divisor of n or k divides n, notation: k|n, if k is a positive integer n = kq for some integer q called the quotient.  A common divisor of two integers m and n is a positive integer k such that k|m and k|n.

Euclidean algorithm  Given two integers m and n, the gcd(m,n) or greatest common divisor of m and n is a common divisor k > 1 such that k is the largest of all common divisors of m and n. The Euclidean algorithm finds the gcd(m, n).  Theorem 3.3.6: If a is a nonnegative integer, b is a positive integer, and r = a mod b, then gcd(a,b) = gcd(b,r)  Example: if a = 120, b = 80, then r = 40 = 120 mod 80.  Thus, gcd(120,80) = gcd(80,40)

3.4 Recursive algorithms  A recursive procedure is a procedure that invokes itself  Example: given a positive integer n, factorial of n is defined as the product of n by all numbers less than n and greater than 0. Notation: n! = n(n-1)(n-2)…3.2.1  Observe that n! = n(n-1)! = n(n-1)(n-2)!, etc.  A recursive algorithm is an algorithm that contains a recursive procedure

Fibonacci sequence  Leonardo Fibonacci (Pisa, Italy, ca )  Fibonacci sequence f 1, f 2,… defined recursively as follows: f 1 = 1 f 2 = 2 f n = f n-1 + f n-2 for n > 3  First terms of the sequence are: 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597,…

3.5 Complexity of algorithms  Complexity: the amount of time and/or space needed to execute the algorithm.  Complexity depends on many factors: data representation type, kind of computer, computer language used, etc.

Types of complexity Best-case time = minimum time needed to execute the algorithm for inputs of size n Worst-case time = maximum time needed to execute the algorithm for inputs of size n Average-case time = average time needed

Order of an algorithm Z Let f and g be functions with domain Z + = {1, 2, 3,…}  f(n) = O(g(n)): f(n) is of order at most g(n)  if there exists a positive constant C 1 such that |f(n)| < C 1 |g(n)| for all but finitely many n  f(n) =  (g(n)): f(n) is of order at least g(n)  if there exists a positive constant C 2 such that |f(n)| > C 2 |g(n)| for all but finitely many n  f(n) =  (g(n)): f(n) is or order g(n) if it is O(g(n)) and  (g(n)).

3.6 Analysis of the Euclidean algorithm Theorem 3.6.1: Suppose that the pair a, b with a > b requires n >1 modulus operations when input to the Euclidean algorithm. Then a > f n+1 and b > f n+1, where {f n } is the Fibonacci sequence.

Number of operations Theorem 3.6.2: If integers in the range 0 to m, m > 8, not both zero, are input to the Euclidean algorithm, then the number of modulus operations required is at most log 3/2 (2m/3)

3.7 The RSA public-key cryptosystem  Cryptosystems: systems for secure communications  Used by government, industry, investigation agencies, etc.  Sender encrypts a message  Receiver decripts the message  RSA (Rivest, Shamir, Adleman) system  Messages are represented as numbers  Based on the fact that no efficient algorithm exists for factoring large digit integers in polynomial time O(n k ).