ALGORITHMS AND COMPLEXITY THEORY

Size: px
Start display at page:

Download "ALGORITHMS AND COMPLEXITY THEORY"

Transcription

1 ALGORITHMS AND COMPLEXITY THEORY Chapter 2: Induction and Recursion Jules-R Tapamo Computer Science- Durban - February 2010 Contents 1 The principle of induction 2 2 recursive procedures Principles Some simple examples Time and storage cost of recursion Recursion Trees correctness of algorithms Some definitions proof of correctness of an algorithm computation of a product using a loop induction Proof of Recursive Procedure

2 2 2 RECURSIVE PROCEDURES 1 The principle of induction Induction is critical to many aspects of algorithms and data structures. In particular, virtually all correctness arguments are based on induction. Suppose we are asked to prove the result (2n 1) = n 2 In other words, we have to show that the expression defined recursively on the left is equally defined by the formula on the right, for all positive integers n. We might proceed as follows. The formula is certainly correct when n = 1, since 1 = 1 2. Suppose it is correct for a specific value of n, say n = k, so that (2k 1) = k 2. This fact can be used to simplify the left hand side when n = k + 1, as follows: (2k + 1) = (2k 1) + (2k + 1) = k 2 + (2k + 1) = (k + 1) 2 So if the result is correct when n = k then it is correct when n = k + 1. In practice, we usually present a proof by induction in more descriptive terms as follows: Here n is read for all n P stand for property. P (0) ( n)(p (n) P (n + 1)) ( n)p (n) P(0): property P holds for 0 P (n) P (n + 1): if P holds for n, then it holds for n + 1 ( n)p (n) : P holds for every n Proofs by induction are then done according to the following format: Induction Basis : verify that the property is true for n=0, Induction step : Assume that the property is true for n and deduce the property is true for n + 1 Hence : result by induction. There are several modified forms of the principle of induction. Sometimes it is convenient to take for the induction basis the value n=0; on other hand it may be appropriate to take a value 2 or 3, since the first few cases may be exceptional. Another useful modification is to take as induction hypothesis the assumption that the result is true for all relevant values k n, rather than n = k alone. This formulation is sometimes called the strong induction. 2 recursive procedures 2.1 Principles Recursion is simply a technique of describing something partly in terms of itself? There are many application of recursion. There are four advantages of recursion programming. For many problems the recursive solution is more natural than the alternative non-recursive solution. It is relatively easy to prove the correctness of recursive procedures.

3 2.2 Some simple examples 3 Recursive procedures are relatively easy to analyze and it is also easy to determine their performance. This analysis produces recurrence relations, many which can easily be solved. Recursive procedures are relatively flexible. But there are problems to solve when recursion is used: Recursive procedures may run slowly than equivalent non-recursive ones. There are two causes of this. Firstly, a compiler may be implement recursive calls badly. Secondly, the recursive procedures we write may be simply inefficient. Recursive procedures require more storage space than their non-recursive counterparts. Each recursive call involves the creation of an activation record, and if the depth of the recursion is large this space penalty maybe significant. 2.2 Some simple examples EXAMPLE T he simplest example of recursion is the factorial function, which is defined by: { 1, p=0 p! = p, p > 0 From this definition we have the following function: int n) Fact1(int 1: int f = 1; 2: for i = 1 to n do 3: f = f * i 4: end for 5: return f Which is a non-recursive version of the algorithm. It is proved that { 1, p=0 p! = p (p 1), p > 0 from which we have the following recursive version of the above function. int Fact2(int p) 1: if ( n == 0) then 2: return 1 3: else 4: return n*fact2(n-1) 5: end if

4 4 2 RECURSIVE PROCEDURES EXAMPLE A s a second example of recursion, we consider the highest common factor (HCF) of two positive integers p and q. A description of Euclid s algorithm for finding the HCF usually goes something like this: Divide p by q to give a remainder r. If r = 0 then the HCF is q. Otherwise repeat with q and r taking place of p and q. The non recursive version of Hcf is int Hcf(Int p, int q) 1: int r 2: r = p mod q 3: while r 0 do 4: p = q 5: q = r 6: r = p mod q 7: end while 8: return q Mathematically Hcf can be formulated as follows: { p if p mod q = 0 hcf(p, q) = hcf(q, pmod q) Otherwise From this formula we can derive the following recursive version of Hcf. int Hcf(Int p, int q) 1: int r 2: begin 3: r = p mod q 4: if r 0 then 5: return q 6: else 7: return Hcf(q,r) 8: end if Definition : Given a recursive procedure P: P is a simple recursion if all recursive calls appear in the the body of P. P is a crossed recursion if P calls Q and Q calls P Time and storage cost of recursion From the implementation, the cost in term of storage associated to recursive procedures is clear. If n is the maximum recursive depth, then the store required is n (p + l + 2) where p represents the space required by the parameters and l that required by the local variables. Where the alternative non-recursive solution requires only a small number of local variables for its operation. The time cost of recursive algorithms are mostly based on recurrence relations. It is then convenient to have the notion of size of a problem, so that if T k represents the cost, however defined, of evaluating a procedure of size k then the recurrence relation defines T k in terms of the cost of evaluating the smaller problem(s) into which it is broken down. For linear recursion (recursion where there is only one call) the size is closely related to the recursive depth and T k is defined in terms of T k 1. For the factorial case we have:

5 2.3 Recursion Trees 5 { b + Tk 1 if k > 0 T k = a if k = 0 where a and b are appropriate constants. T n can be determine simple by a process of substitution as follows: T n = b + T n 1 = b + b + T n 2 = 2 b + T n 2. = b n + T 0 = bn + a It means the running time of the recursive version of factorial T n is O(n) ( linear ). 2.3 Recursion Trees Let P be a recursive procedure with only simple recursive calls. There are n recursive calls, as shown in the following algorithm: 1: P(var) 2: if Test(var) then 3: return(val) 4: else 5: Instructions 1 6: P (φ 1 (var)) 7:... 8:... 9: P (φ n (var)) 10: Instructions n+1 11: end if To each call P (v) of P, we can associate a tree A(v) called, execution tree of P for the call P (v), recursively defined as follows : If T est(v) is true, then A(v) is reduced to the root: A(v) = V al If T est(v) is not true, then A(v) is equal to: figure 2.1: Recursion tree This tree is easily extendable to any other form of recursion.

6 6 3 CORRECTNESS OF ALGORITHMS EXAMPLE Sum of elements of an array. To compute the sum of n elements(real) of an array T [1 : n] S(n) = n T [i] It is sufficient to point out that if n = 0, then the sum is equal to 0 and if n 1, S(n) = S(n 1) + T [n] and we have the following recursive algorithm: 1: int SUM( float [] T, int n) 2: if n == 0 then 3: return 0 4: else 5: return(sum(t,n-1)+t[n])) 6: end if Consider for instance the call of SUM(T, 2) The execution tree will be as shown in figure 2.2: i=1 figure 2.2: Recursion tree of SUM(T, 2) 3 correctness of algorithms 3.1 Some definitions It is generally known that the proof of the correctness of a program is not an easy task. We will use informal methods to prove that the recursive procedures discussed in here work as specified. The main proof is done through well-founded induction. It is demonstrated that the program works correctly for all base cases. The induction hypothesis is then all recursive calls of the the procedure work correctly, provided the initial states meet the preconditions of the procedure. Given this hypothesis, the inductive step requires one to show that, under the inductive hypothesis, the program runs correctly, given that the domain is well founded. Before any attempt of proof of program we will give some useful definitions. A block is a section of code with one entry and one exit point. Blocks are main subdivisions of program code and procedure code. A procedure is a block with a name, so it can be called. It usually has parameters, which are input or output. A function is a procedure with some output parameters. Control structure are mechanisms for causing various blocks to be executed. The elementary control structure are: sequence of blocks

7 3.2 proof of correctness of an algorithm 7 alteration ( if condition then true-block, else false-block) procedure call A precondition is an assertion concerning the initial state of a block and postcondition is an assertion regarding the final state of a block. Proving the correctness of a procedure means proving certain logical statements about this procedure. A block is said to be partially correct with respect to the precondition P and the postcondition Q if the final state of the code always satisfies Q, provided that the code starts in P and provided that it terminates. The code is said to be totally correct if for each state satisfying P the code terminates with a final state satisfying Q. EXAMPLE A. For an algorithm to compute a product of nonnegative integers precondition : the input variables m and n are nonnegative integers. postcondition: The output variable p equals m.n. B. For the algorithm to find the quotient and the remainder of the division of one positive integer by another. precondition : the input variables m and n are positive integers. postcondition: The output variables q and r are integers such that a = b.q + r and 0 r < b. 3.2 proof of correctness of an algorithm The proof of correctness of an algorithm consists of showing that if the preconditions for the algorithm is true for collection of values for the input variables and if the statements of the statements of the algorithms are executed, then the post-condition is also true. To prove the correctness of an algorithm we will divide this algorithm into sections with assertions about current state of algorithm variables inserted at adequate chosen points; [Assertion 1: precondition of the algorithm] {algorithms statements} [Assertions 2] {algorithms statements} [Assertions k-1] {algorithms statements} [Assertion 1: post-condition of the algorithm] Successive pairs of assertions are treated as pre- and post-conditions for algorithms between them. Then for i = 1, 2,..., k 1, IF we can prove that if assertion i is true and algorithm statement between assertion i and assertion i+1 are executed, then assertion i+1 is true, THEN the algorithm is correct. Loop invariant is a condition on the variables within a loop, which remains true during the iterations of the loop. The method of loop invariants is used to prove the correctness of a loop with respect to certain pre- and post-conditions. It is based on the principle of Mathematical induction. Suppose an algorithm contains a while loop and that entry to this loop is restricted by a condition G, called guard. And this loop is specified as follows:

8 8 3 CORRECTNESS OF ALGORITHMS [pre-condition of the loop] WHILE(G) [Statements in the body of loop. with no statement branching outside the loop] [END WHILE] Then there theorem assuring that the loop is correct. Theorem:Loop Invariant Theorem: Let a while Loop with a Guard G be given, together with pre- and post -conditions, and a loop invariant I(n). If the following four properties are true, then the loop is correct with respect to its pre- and postconditions: A. Basis property : the precondition for the loop implies that I(0) is true before the first iteration of the loop. B. Inductive property : If the G I(k) =true for k 0 before an iteration of the loop, then I(k + 1) is true. C. Eventual Falsity of Guard : After a finite number iterations of the loop, the guard becomes false. D. Correctness of the post-condition: If N is the least number of the iterations after which G is false and I(N) is true, then the values of the algorithm will be as specified in the post-condition of the loop computation of a product using a loop we want to use a loop to compute the product m x, we have the variables i and product with i = 0 and product = 0. the loop is defined as follows: [pre-condition: m is a nonnegative integer, x is a real, i=0, and product =0] WHILE ( i<>m ) (1) product := product +x (2) i := i+1 ENDWHILE [post-condition: product = m*x] the loop invariant is I(n) : i = n and product = n.x and the guard G of the while loop is G : n <> i. A. Basis property : implies that I(0) is true before the first iteration of the loop. I(0) is i = 0 and product = 0.x which is true before the first iteration. B. Inductive property : If the G I(k) =true for k 0 before an iteration of the loop, then I(k + 1) is true. product old = k.x and i = k since i <> m, the guard is passed and from the statement (1) we have a product new = product old + x = k.x + x = (k + 1)x, after execution of statement (2) we have i new = i old + 1 = k + 1

9 3.3 induction Proof of Recursive Procedure 9 C. Eventual Falsity of Guard : After a finite number iterations of the loop, the guard becomes false. for all n 0, if the loop is iterated n times, then i = n and product =n.x. so after m iteration of the loop, i =m. thus G becomes false after m iterations. D. Correctness of the post-condition: If N is the least number of the iterations after which G is false and I(N) is true, then the values of the algorithm will be as specified in the post-condition. G is false and I(n) is true means product = m.x 3.3 induction Proof of Recursive Procedure Definition : The Domain or Universe of Discourse is the collection of all persons, ideas, symbols, data structures, etc. that affect the logical argument under consideration. The elements of the domain are called individuals. An individual can be, a person, a number, a data structure, or anything we want to reason about. EXAMPLE if the domain consists of persons, individuals can be represented by their names. In the case of natural numbers, individuals are digits representing these numbers( i.e 0,1,2,3,...) In the proposition George and Jack are siblings, George and Jack are individuals in the domain of persons. In the proposition The sum of 4 and 7 is 11, 4, 7 and 11 are individuals in domain of numbers. The fact that the recursion will terminate is crucial, and proofs by induction are unsound unless this fact can be established. Hence it is necessary to introduce the notion of descending sequence, is a sequence of smaller and smaller elements. A Domain in which all descending sequences are finite is said to be well founded. Recursive procedures are partially correct if the base cases are correct and if induction step can be established. Let the following { be the algorithm to find an integer Key in a sorted array Vector[First, Last] of integers, true if Key is found and save its position in Position which returns f alse Otherwise boolean search(int First, int Last, int Key, int [] Vector) 1: if (First > Last ) then 2: return false 3: else 4: Middle = (First+Last)/ 2; 5: if (Key < Vector[Middle]) then 6: return search(first, Middle-1,Key, Vector); 7: else if (Key >Vector[Middle]) then 8: return search(middle+1,last,key,vector); 9: else 10: Position = Middle; 11: return true 12: end if 13: end if

10 10 3 CORRECTNESS OF ALGORITHMS EXAMPLE T o show that the above function is totally correct, it must be shown that it is partially correct and that the domain is well founded. The domain consists of all intervals from a to b, where a and b can assume any values inside the range of the array vector. Induction basis: The base case is the case in which there is no element between First and Last, and the function will return false. Induction hypothesis Choose any value for First and Last. These 2 values provide an interval, and the inductive hypothesis is that the function works for all proper subintervals of this interval. Induction step : Since the array Vector is sorted., Key must be in the interval from First to Middle -1 if Key< Vector[Middle], and it must be in the interval Middle+1 to Last if Key > Vector[Middle]. Both intervals are proper subintervals of the interval with the end points First and Last, and by induction the procedure is correct for these intervals. Then the procedure works correctly. Domain well founded The domain is well founded because all sequence in which the subsequent element is a proper subinterval of preceding element must be finite. Bibliography 1. Baase S. and Gelder A., Computer Algorithms: Introduction to Design and Analysis, Addison Wesley, Knuth D.E., The art of Computer Programming: Fundamental Algorithms, Addison-Wesley, 1997.

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)!

HOMEWORK 5 SOLUTIONS. n!f n (1) lim. ln x n! + xn x. 1 = G n 1 (x). (2) k + 1 n. (n 1)! Math 7 Fall 205 HOMEWORK 5 SOLUTIONS Problem. 2008 B2 Let F 0 x = ln x. For n 0 and x > 0, let F n+ x = 0 F ntdt. Evaluate n!f n lim n ln n. By directly computing F n x for small n s, we obtain the following

More information

Lecture Notes on Linear Search

Lecture Notes on Linear Search Lecture Notes on Linear Search 15-122: Principles of Imperative Computation Frank Pfenning Lecture 5 January 29, 2013 1 Introduction One of the fundamental and recurring problems in computer science is

More information

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.

Elementary Number Theory and Methods of Proof. CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook. Elementary Number Theory and Methods of Proof CSE 215, Foundations of Computer Science Stony Brook University http://www.cs.stonybrook.edu/~cse215 1 Number theory Properties: 2 Properties of integers (whole

More information

Mathematical Induction. Lecture 10-11

Mathematical Induction. Lecture 10-11 Mathematical Induction Lecture 10-11 Menu Mathematical Induction Strong Induction Recursive Definitions Structural Induction Climbing an Infinite Ladder Suppose we have an infinite ladder: 1. We can reach

More information

8 Divisibility and prime numbers

8 Divisibility and prime numbers 8 Divisibility and prime numbers 8.1 Divisibility In this short section we extend the concept of a multiple from the natural numbers to the integers. We also summarize several other terms that express

More information

Continued Fractions and the Euclidean Algorithm

Continued Fractions and the Euclidean Algorithm Continued Fractions and the Euclidean Algorithm Lecture notes prepared for MATH 326, Spring 997 Department of Mathematics and Statistics University at Albany William F Hammond Table of Contents Introduction

More information

3. Mathematical Induction

3. Mathematical Induction 3. MATHEMATICAL INDUCTION 83 3. Mathematical Induction 3.1. First Principle of Mathematical Induction. Let P (n) be a predicate with domain of discourse (over) the natural numbers N = {0, 1,,...}. If (1)

More information

CS 103X: Discrete Structures Homework Assignment 3 Solutions

CS 103X: Discrete Structures Homework Assignment 3 Solutions CS 103X: Discrete Structures Homework Assignment 3 s Exercise 1 (20 points). On well-ordering and induction: (a) Prove the induction principle from the well-ordering principle. (b) Prove the well-ordering

More information

SECTION 10-2 Mathematical Induction

SECTION 10-2 Mathematical Induction 73 0 Sequences and Series 6. Approximate e 0. using the first five terms of the series. Compare this approximation with your calculator evaluation of e 0.. 6. Approximate e 0.5 using the first five terms

More information

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion

CHAPTER 5. Number Theory. 1. Integers and Division. Discussion CHAPTER 5 Number Theory 1. Integers and Division 1.1. Divisibility. Definition 1.1.1. Given two integers a and b we say a divides b if there is an integer c such that b = ac. If a divides b, we write a

More information

Math 55: Discrete Mathematics

Math 55: Discrete Mathematics Math 55: Discrete Mathematics UC Berkeley, Fall 2011 Homework # 5, due Wednesday, February 22 5.1.4 Let P (n) be the statement that 1 3 + 2 3 + + n 3 = (n(n + 1)/2) 2 for the positive integer n. a) What

More information

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers.

MATHEMATICAL INDUCTION. Mathematical Induction. This is a powerful method to prove properties of positive integers. MATHEMATICAL INDUCTION MIGUEL A LERMA (Last updated: February 8, 003) Mathematical Induction This is a powerful method to prove properties of positive integers Principle of Mathematical Induction Let P

More information

8 Primes and Modular Arithmetic

8 Primes and Modular Arithmetic 8 Primes and Modular Arithmetic 8.1 Primes and Factors Over two millennia ago already, people all over the world were considering the properties of numbers. One of the simplest concepts is prime numbers.

More information

Handout #1: Mathematical Reasoning

Handout #1: Mathematical Reasoning Math 101 Rumbos Spring 2010 1 Handout #1: Mathematical Reasoning 1 Propositional Logic A proposition is a mathematical statement that it is either true or false; that is, a statement whose certainty or

More information

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson

Mathematics for Computer Science/Software Engineering. Notes for the course MSM1F3 Dr. R. A. Wilson Mathematics for Computer Science/Software Engineering Notes for the course MSM1F3 Dr. R. A. Wilson October 1996 Chapter 1 Logic Lecture no. 1. We introduce the concept of a proposition, which is a statement

More information

Basic Proof Techniques

Basic Proof Techniques Basic Proof Techniques David Ferry dsf43@truman.edu September 13, 010 1 Four Fundamental Proof Techniques When one wishes to prove the statement P Q there are four fundamental approaches. This document

More information

What Is Recursion? Recursion. Binary search example postponed to end of lecture

What Is Recursion? Recursion. Binary search example postponed to end of lecture Recursion Binary search example postponed to end of lecture What Is Recursion? Recursive call A method call in which the method being called is the same as the one making the call Direct recursion Recursion

More information

Section IV.1: Recursive Algorithms and Recursion Trees

Section IV.1: Recursive Algorithms and Recursion Trees Section IV.1: Recursive Algorithms and Recursion Trees Definition IV.1.1: A recursive algorithm is an algorithm that solves a problem by (1) reducing it to an instance of the same problem with smaller

More information

Lecture 3: Finding integer solutions to systems of linear equations

Lecture 3: Finding integer solutions to systems of linear equations Lecture 3: Finding integer solutions to systems of linear equations Algorithmic Number Theory (Fall 2014) Rutgers University Swastik Kopparty Scribe: Abhishek Bhrushundi 1 Overview The goal of this lecture

More information

Data Structures and Algorithms Written Examination

Data Structures and Algorithms Written Examination Data Structures and Algorithms Written Examination 22 February 2013 FIRST NAME STUDENT NUMBER LAST NAME SIGNATURE Instructions for students: Write First Name, Last Name, Student Number and Signature where

More information

Regular Languages and Finite Automata

Regular Languages and Finite Automata Regular Languages and Finite Automata 1 Introduction Hing Leung Department of Computer Science New Mexico State University Sep 16, 2010 In 1943, McCulloch and Pitts [4] published a pioneering work on a

More information

Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1

Recursive Algorithms. Recursion. Motivating Example Factorial Recall the factorial function. { 1 if n = 1 n! = n (n 1)! if n > 1 Recursion Slides by Christopher M Bourke Instructor: Berthe Y Choueiry Fall 007 Computer Science & Engineering 35 Introduction to Discrete Mathematics Sections 71-7 of Rosen cse35@cseunledu Recursive Algorithms

More information

Full and Complete Binary Trees

Full and Complete Binary Trees Full and Complete Binary Trees Binary Tree Theorems 1 Here are two important types of binary trees. Note that the definitions, while similar, are logically independent. Definition: a binary tree T is full

More information

Sample Induction Proofs

Sample Induction Proofs Math 3 Worksheet: Induction Proofs III, Sample Proofs A.J. Hildebrand Sample Induction Proofs Below are model solutions to some of the practice problems on the induction worksheets. The solutions given

More information

Regression Verification: Status Report

Regression Verification: Status Report Regression Verification: Status Report Presentation by Dennis Felsing within the Projektgruppe Formale Methoden der Softwareentwicklung 2013-12-11 1/22 Introduction How to prevent regressions in software

More information

WRITING PROOFS. Christopher Heil Georgia Institute of Technology

WRITING PROOFS. Christopher Heil Georgia Institute of Technology WRITING PROOFS Christopher Heil Georgia Institute of Technology A theorem is just a statement of fact A proof of the theorem is a logical explanation of why the theorem is true Many theorems have this

More information

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products

Chapter 3. Cartesian Products and Relations. 3.1 Cartesian Products Chapter 3 Cartesian Products and Relations The material in this chapter is the first real encounter with abstraction. Relations are very general thing they are a special type of subset. After introducing

More information

Binary Search Trees CMPSC 122

Binary Search Trees CMPSC 122 Binary Search Trees CMPSC 122 Note: This notes packet has significant overlap with the first set of trees notes I do in CMPSC 360, but goes into much greater depth on turning BSTs into pseudocode than

More information

MATH 4330/5330, Fourier Analysis Section 11, The Discrete Fourier Transform

MATH 4330/5330, Fourier Analysis Section 11, The Discrete Fourier Transform MATH 433/533, Fourier Analysis Section 11, The Discrete Fourier Transform Now, instead of considering functions defined on a continuous domain, like the interval [, 1) or the whole real line R, we wish

More information

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm

Kevin James. MTHSC 412 Section 2.4 Prime Factors and Greatest Comm MTHSC 412 Section 2.4 Prime Factors and Greatest Common Divisor Greatest Common Divisor Definition Suppose that a, b Z. Then we say that d Z is a greatest common divisor (gcd) of a and b if the following

More information

Loop Invariants and Binary Search

Loop Invariants and Binary Search Loop Invariants and Binary Search Chapter 4.3.3 and 9.3.1-1 - Outline Ø Iterative Algorithms, Assertions and Proofs of Correctness Ø Binary Search: A Case Study - 2 - Outline Ø Iterative Algorithms, Assertions

More information

6.080/6.089 GITCS Feb 12, 2008. Lecture 3

6.080/6.089 GITCS Feb 12, 2008. Lecture 3 6.8/6.89 GITCS Feb 2, 28 Lecturer: Scott Aaronson Lecture 3 Scribe: Adam Rogal Administrivia. Scribe notes The purpose of scribe notes is to transcribe our lectures. Although I have formal notes of my

More information

Reading 13 : Finite State Automata and Regular Expressions

Reading 13 : Finite State Automata and Regular Expressions CS/Math 24: Introduction to Discrete Mathematics Fall 25 Reading 3 : Finite State Automata and Regular Expressions Instructors: Beck Hasti, Gautam Prakriya In this reading we study a mathematical model

More information

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors.

The Prime Numbers. Definition. A prime number is a positive integer with exactly two positive divisors. The Prime Numbers Before starting our study of primes, we record the following important lemma. Recall that integers a, b are said to be relatively prime if gcd(a, b) = 1. Lemma (Euclid s Lemma). If gcd(a,

More information

Real Roots of Univariate Polynomials with Real Coefficients

Real Roots of Univariate Polynomials with Real Coefficients Real Roots of Univariate Polynomials with Real Coefficients mostly written by Christina Hewitt March 22, 2012 1 Introduction Polynomial equations are used throughout mathematics. When solving polynomials

More information

4.5 Linear Dependence and Linear Independence

4.5 Linear Dependence and Linear Independence 4.5 Linear Dependence and Linear Independence 267 32. {v 1, v 2 }, where v 1, v 2 are collinear vectors in R 3. 33. Prove that if S and S are subsets of a vector space V such that S is a subset of S, then

More information

Answer Key for California State Standards: Algebra I

Answer Key for California State Standards: Algebra I Algebra I: Symbolic reasoning and calculations with symbols are central in algebra. Through the study of algebra, a student develops an understanding of the symbolic language of mathematics and the sciences.

More information

a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2.

a 11 x 1 + a 12 x 2 + + a 1n x n = b 1 a 21 x 1 + a 22 x 2 + + a 2n x n = b 2. Chapter 1 LINEAR EQUATIONS 1.1 Introduction to linear equations A linear equation in n unknowns x 1, x,, x n is an equation of the form a 1 x 1 + a x + + a n x n = b, where a 1, a,..., a n, b are given

More information

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics

Undergraduate Notes in Mathematics. Arkansas Tech University Department of Mathematics Undergraduate Notes in Mathematics Arkansas Tech University Department of Mathematics An Introductory Single Variable Real Analysis: A Learning Approach through Problem Solving Marcel B. Finan c All Rights

More information

Lecture Notes on Polynomials

Lecture Notes on Polynomials Lecture Notes on Polynomials Arne Jensen Department of Mathematical Sciences Aalborg University c 008 Introduction These lecture notes give a very short introduction to polynomials with real and complex

More information

DIVISIBILITY AND GREATEST COMMON DIVISORS

DIVISIBILITY AND GREATEST COMMON DIVISORS DIVISIBILITY AND GREATEST COMMON DIVISORS KEITH CONRAD 1 Introduction We will begin with a review of divisibility among integers, mostly to set some notation and to indicate its properties Then we will

More information

Notes on Complexity Theory Last updated: August, 2011. Lecture 1

Notes on Complexity Theory Last updated: August, 2011. Lecture 1 Notes on Complexity Theory Last updated: August, 2011 Jonathan Katz Lecture 1 1 Turing Machines I assume that most students have encountered Turing machines before. (Students who have not may want to look

More information

Regular Expressions and Automata using Haskell

Regular Expressions and Automata using Haskell Regular Expressions and Automata using Haskell Simon Thompson Computing Laboratory University of Kent at Canterbury January 2000 Contents 1 Introduction 2 2 Regular Expressions 2 3 Matching regular expressions

More information

Introduction. Appendix D Mathematical Induction D1

Introduction. Appendix D Mathematical Induction D1 Appendix D Mathematical Induction D D Mathematical Induction Use mathematical induction to prove a formula. Find a sum of powers of integers. Find a formula for a finite sum. Use finite differences to

More information

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs

CHAPTER 3. Methods of Proofs. 1. Logical Arguments and Formal Proofs CHAPTER 3 Methods of Proofs 1. Logical Arguments and Formal Proofs 1.1. Basic Terminology. An axiom is a statement that is given to be true. A rule of inference is a logical rule that is used to deduce

More information

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT?

WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT? WHAT ARE MATHEMATICAL PROOFS AND WHY THEY ARE IMPORTANT? introduction Many students seem to have trouble with the notion of a mathematical proof. People that come to a course like Math 216, who certainly

More information

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl)

How To Know If A Domain Is Unique In An Octempo (Euclidean) Or Not (Ecl) Subsets of Euclidean domains possessing a unique division algorithm Andrew D. Lewis 2009/03/16 Abstract Subsets of a Euclidean domain are characterised with the following objectives: (1) ensuring uniqueness

More information

Notes on Determinant

Notes on Determinant ENGG2012B Advanced Engineering Mathematics Notes on Determinant Lecturer: Kenneth Shum Lecture 9-18/02/2013 The determinant of a system of linear equations determines whether the solution is unique, without

More information

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12

CONTINUED FRACTIONS AND PELL S EQUATION. Contents 1. Continued Fractions 1 2. Solution to Pell s Equation 9 References 12 CONTINUED FRACTIONS AND PELL S EQUATION SEUNG HYUN YANG Abstract. In this REU paper, I will use some important characteristics of continued fractions to give the complete set of solutions to Pell s equation.

More information

NOTES ON LINEAR TRANSFORMATIONS

NOTES ON LINEAR TRANSFORMATIONS NOTES ON LINEAR TRANSFORMATIONS Definition 1. Let V and W be vector spaces. A function T : V W is a linear transformation from V to W if the following two properties hold. i T v + v = T v + T v for all

More information

Lecture 1: Course overview, circuits, and formulas

Lecture 1: Course overview, circuits, and formulas Lecture 1: Course overview, circuits, and formulas Topics in Complexity Theory and Pseudorandomness (Spring 2013) Rutgers University Swastik Kopparty Scribes: John Kim, Ben Lund 1 Course Information Swastik

More information

6.2 Permutations continued

6.2 Permutations continued 6.2 Permutations continued Theorem A permutation on a finite set A is either a cycle or can be expressed as a product (composition of disjoint cycles. Proof is by (strong induction on the number, r, of

More information

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012

COMP 250 Fall 2012 lecture 2 binary representations Sept. 11, 2012 Binary numbers The reason humans represent numbers using decimal (the ten digits from 0,1,... 9) is that we have ten fingers. There is no other reason than that. There is nothing special otherwise about

More information

The Classes P and NP

The Classes P and NP The Classes P and NP We now shift gears slightly and restrict our attention to the examination of two families of problems which are very important to computer scientists. These families constitute the

More information

Mathematical Induction. Mary Barnes Sue Gordon

Mathematical Induction. Mary Barnes Sue Gordon Mathematics Learning Centre Mathematical Induction Mary Barnes Sue Gordon c 1987 University of Sydney Contents 1 Mathematical Induction 1 1.1 Why do we need proof by induction?.... 1 1. What is proof by

More information

MATH 289 PROBLEM SET 4: NUMBER THEORY

MATH 289 PROBLEM SET 4: NUMBER THEORY MATH 289 PROBLEM SET 4: NUMBER THEORY 1. The greatest common divisor If d and n are integers, then we say that d divides n if and only if there exists an integer q such that n = qd. Notice that if d divides

More information

SCORE SETS IN ORIENTED GRAPHS

SCORE SETS IN ORIENTED GRAPHS Applicable Analysis and Discrete Mathematics, 2 (2008), 107 113. Available electronically at http://pefmath.etf.bg.ac.yu SCORE SETS IN ORIENTED GRAPHS S. Pirzada, T. A. Naikoo The score of a vertex v in

More information

MATH10040 Chapter 2: Prime and relatively prime numbers

MATH10040 Chapter 2: Prime and relatively prime numbers MATH10040 Chapter 2: Prime and relatively prime numbers Recall the basic definition: 1. Prime numbers Definition 1.1. Recall that a positive integer is said to be prime if it has precisely two positive

More information

k, then n = p2α 1 1 pα k

k, then n = p2α 1 1 pα k Powers of Integers An integer n is a perfect square if n = m for some integer m. Taking into account the prime factorization, if m = p α 1 1 pα k k, then n = pα 1 1 p α k k. That is, n is a perfect square

More information

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity.

Catalan Numbers. Thomas A. Dowling, Department of Mathematics, Ohio State Uni- versity. 7 Catalan Numbers Thomas A. Dowling, Department of Mathematics, Ohio State Uni- Author: versity. Prerequisites: The prerequisites for this chapter are recursive definitions, basic counting principles,

More information

Set theory as a foundation for mathematics

Set theory as a foundation for mathematics V I I I : Set theory as a foundation for mathematics This material is basically supplementary, and it was not covered in the course. In the first section we discuss the basic axioms of set theory and the

More information

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z

FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z FACTORING POLYNOMIALS IN THE RING OF FORMAL POWER SERIES OVER Z DANIEL BIRMAJER, JUAN B GIL, AND MICHAEL WEINER Abstract We consider polynomials with integer coefficients and discuss their factorization

More information

Factoring Algorithms

Factoring Algorithms Factoring Algorithms The p 1 Method and Quadratic Sieve November 17, 2008 () Factoring Algorithms November 17, 2008 1 / 12 Fermat s factoring method Fermat made the observation that if n has two factors

More information

On strong fairness in UNITY

On strong fairness in UNITY On strong fairness in UNITY H.P.Gumm, D.Zhukov Fachbereich Mathematik und Informatik Philipps Universität Marburg {gumm,shukov}@mathematik.uni-marburg.de Abstract. In [6] Tsay and Bagrodia present a correct

More information

So let us begin our quest to find the holy grail of real analysis.

So let us begin our quest to find the holy grail of real analysis. 1 Section 5.2 The Complete Ordered Field: Purpose of Section We present an axiomatic description of the real numbers as a complete ordered field. The axioms which describe the arithmetic of the real numbers

More information

Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally

Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally Recurrence Relations Many algorithms, particularly divide and conquer algorithms, have time complexities which are naturally modeled by recurrence relations. A recurrence relation is an equation which

More information

7. Some irreducible polynomials

7. Some irreducible polynomials 7. Some irreducible polynomials 7.1 Irreducibles over a finite field 7.2 Worked examples Linear factors x α of a polynomial P (x) with coefficients in a field k correspond precisely to roots α k [1] of

More information

Symbol Tables. Introduction

Symbol Tables. Introduction Symbol Tables Introduction A compiler needs to collect and use information about the names appearing in the source program. This information is entered into a data structure called a symbol table. The

More information

Why? A central concept in Computer Science. Algorithms are ubiquitous.

Why? A central concept in Computer Science. Algorithms are ubiquitous. Analysis of Algorithms: A Brief Introduction Why? A central concept in Computer Science. Algorithms are ubiquitous. Using the Internet (sending email, transferring files, use of search engines, online

More information

3. INNER PRODUCT SPACES

3. INNER PRODUCT SPACES . INNER PRODUCT SPACES.. Definition So far we have studied abstract vector spaces. These are a generalisation of the geometric spaces R and R. But these have more structure than just that of a vector space.

More information

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom.

Some Polynomial Theorems. John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom. Some Polynomial Theorems by John Kennedy Mathematics Department Santa Monica College 1900 Pico Blvd. Santa Monica, CA 90405 rkennedy@ix.netcom.com This paper contains a collection of 31 theorems, lemmas,

More information

ML for the Working Programmer

ML for the Working Programmer ML for the Working Programmer 2nd edition Lawrence C. Paulson University of Cambridge CAMBRIDGE UNIVERSITY PRESS CONTENTS Preface to the Second Edition Preface xiii xv 1 Standard ML 1 Functional Programming

More information

Continued Fractions. Darren C. Collins

Continued Fractions. Darren C. Collins Continued Fractions Darren C Collins Abstract In this paper, we discuss continued fractions First, we discuss the definition and notation Second, we discuss the development of the subject throughout history

More information

Indiana State Core Curriculum Standards updated 2009 Algebra I

Indiana State Core Curriculum Standards updated 2009 Algebra I Indiana State Core Curriculum Standards updated 2009 Algebra I Strand Description Boardworks High School Algebra presentations Operations With Real Numbers Linear Equations and A1.1 Students simplify and

More information

Examination paper for MA0301 Elementær diskret matematikk

Examination paper for MA0301 Elementær diskret matematikk Department of Mathematical Sciences Examination paper for MA0301 Elementær diskret matematikk Academic contact during examination: Iris Marjan Smit a, Sverre Olaf Smalø b Phone: a 9285 0781, b 7359 1750

More information

LAKE ELSINORE UNIFIED SCHOOL DISTRICT

LAKE ELSINORE UNIFIED SCHOOL DISTRICT LAKE ELSINORE UNIFIED SCHOOL DISTRICT Title: PLATO Algebra 1-Semester 2 Grade Level: 10-12 Department: Mathematics Credit: 5 Prerequisite: Letter grade of F and/or N/C in Algebra 1, Semester 2 Course Description:

More information

Sequential Data Structures

Sequential Data Structures Sequential Data Structures In this lecture we introduce the basic data structures for storing sequences of objects. These data structures are based on arrays and linked lists, which you met in first year

More information

Chapter 11 Number Theory

Chapter 11 Number Theory Chapter 11 Number Theory Number theory is one of the oldest branches of mathematics. For many years people who studied number theory delighted in its pure nature because there were few practical applications

More information

Optimal Binary Search Trees Meet Object Oriented Programming

Optimal Binary Search Trees Meet Object Oriented Programming Optimal Binary Search Trees Meet Object Oriented Programming Stuart Hansen and Lester I. McCann Computer Science Department University of Wisconsin Parkside Kenosha, WI 53141 {hansen,mccann}@cs.uwp.edu

More information

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p.

Page 331, 38.4 Suppose a is a positive integer and p is a prime. Prove that p a if and only if the prime factorization of a contains p. Page 331, 38.2 Assignment #11 Solutions Factor the following positive integers into primes. a. 25 = 5 2. b. 4200 = 2 3 3 5 2 7. c. 10 10 = 2 10 5 10. d. 19 = 19. e. 1 = 1. Page 331, 38.4 Suppose a is a

More information

Midterm Practice Problems

Midterm Practice Problems 6.042/8.062J Mathematics for Computer Science October 2, 200 Tom Leighton, Marten van Dijk, and Brooke Cowan Midterm Practice Problems Problem. [0 points] In problem set you showed that the nand operator

More information

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include 2 + 5.

PUTNAM TRAINING POLYNOMIALS. Exercises 1. Find a polynomial with integral coefficients whose zeros include 2 + 5. PUTNAM TRAINING POLYNOMIALS (Last updated: November 17, 2015) Remark. This is a list of exercises on polynomials. Miguel A. Lerma Exercises 1. Find a polynomial with integral coefficients whose zeros include

More information

Mathematical Induction

Mathematical Induction Mathematical Induction In logic, we often want to prove that every member of an infinite set has some feature. E.g., we would like to show: N 1 : is a number 1 : has the feature Φ ( x)(n 1 x! 1 x) How

More information

Incenter Circumcenter

Incenter Circumcenter TRIANGLE: Centers: Incenter Incenter is the center of the inscribed circle (incircle) of the triangle, it is the point of intersection of the angle bisectors of the triangle. The radius of incircle is

More information

3 Some Integer Functions

3 Some Integer Functions 3 Some Integer Functions A Pair of Fundamental Integer Functions The integer function that is the heart of this section is the modulo function. However, before getting to it, let us look at some very simple

More information

INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS

INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS INDISTINGUISHABILITY OF ABSOLUTELY CONTINUOUS AND SINGULAR DISTRIBUTIONS STEVEN P. LALLEY AND ANDREW NOBEL Abstract. It is shown that there are no consistent decision rules for the hypothesis testing problem

More information

Data Structures Fibonacci Heaps, Amortized Analysis

Data Structures Fibonacci Heaps, Amortized Analysis Chapter 4 Data Structures Fibonacci Heaps, Amortized Analysis Algorithm Theory WS 2012/13 Fabian Kuhn Fibonacci Heaps Lacy merge variant of binomial heaps: Do not merge trees as long as possible Structure:

More information

Modélisation et résolutions numérique et symbolique

Modélisation et résolutions numérique et symbolique Modélisation et résolutions numérique et symbolique via les logiciels Maple et Matlab Jeremy Berthomieu Mohab Safey El Din Stef Graillat Mohab.Safey@lip6.fr Outline Previous course: partial review of what

More information

Formal Verification of Software

Formal Verification of Software Formal Verification of Software Sabine Broda Department of Computer Science/FCUP 12 de Novembro de 2014 Sabine Broda (DCC-FCUP) Formal Verification of Software 12 de Novembro de 2014 1 / 26 Formal Verification

More information

Rigorous Software Development CSCI-GA 3033-009

Rigorous Software Development CSCI-GA 3033-009 Rigorous Software Development CSCI-GA 3033-009 Instructor: Thomas Wies Spring 2013 Lecture 11 Semantics of Programming Languages Denotational Semantics Meaning of a program is defined as the mathematical

More information

Math 4310 Handout - Quotient Vector Spaces

Math 4310 Handout - Quotient Vector Spaces Math 4310 Handout - Quotient Vector Spaces Dan Collins The textbook defines a subspace of a vector space in Chapter 4, but it avoids ever discussing the notion of a quotient space. This is understandable

More information

Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; }

Functions Recursion. C++ functions. Declare/prototype. Define. Call. int myfunction (int ); int myfunction (int x){ int y = x*x; return y; } Functions Recursion C++ functions Declare/prototype int myfunction (int ); Define int myfunction (int x){ int y = x*x; return y; Call int a; a = myfunction (7); function call flow types type of function

More information

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1.

Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology Professors Erik Demaine and Shafi Goldwasser Quiz 1. Introduction to Algorithms March 10, 2004 Massachusetts Institute of Technology 6.046J/18.410J Professors Erik Demaine and Shafi Goldwasser Quiz 1 Quiz 1 Do not open this quiz booklet until you are directed

More information

Dynamic Programming. Lecture 11. 11.1 Overview. 11.2 Introduction

Dynamic Programming. Lecture 11. 11.1 Overview. 11.2 Introduction Lecture 11 Dynamic Programming 11.1 Overview Dynamic Programming is a powerful technique that allows one to solve many different types of problems in time O(n 2 ) or O(n 3 ) for which a naive approach

More information

csci 210: Data Structures Recursion

csci 210: Data Structures Recursion csci 210: Data Structures Recursion Summary Topics recursion overview simple examples Sierpinski gasket Hanoi towers Blob check READING: GT textbook chapter 3.5 Recursion In general, a method of defining

More information

26 Integers: Multiplication, Division, and Order

26 Integers: Multiplication, Division, and Order 26 Integers: Multiplication, Division, and Order Integer multiplication and division are extensions of whole number multiplication and division. In multiplying and dividing integers, the one new issue

More information

Chapter 3. Distribution Problems. 3.1 The idea of a distribution. 3.1.1 The twenty-fold way

Chapter 3. Distribution Problems. 3.1 The idea of a distribution. 3.1.1 The twenty-fold way Chapter 3 Distribution Problems 3.1 The idea of a distribution Many of the problems we solved in Chapter 1 may be thought of as problems of distributing objects (such as pieces of fruit or ping-pong balls)

More information

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem)

Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem) Some facts about polynomials modulo m (Full proof of the Fingerprinting Theorem) In order to understand the details of the Fingerprinting Theorem on fingerprints of different texts from Chapter 19 of the

More information

Overview of Violations of the Basic Assumptions in the Classical Normal Linear Regression Model

Overview of Violations of the Basic Assumptions in the Classical Normal Linear Regression Model Overview of Violations of the Basic Assumptions in the Classical Normal Linear Regression Model 1 September 004 A. Introduction and assumptions The classical normal linear regression model can be written

More information

1 if 1 x 0 1 if 0 x 1

1 if 1 x 0 1 if 0 x 1 Chapter 3 Continuity In this chapter we begin by defining the fundamental notion of continuity for real valued functions of a single real variable. When trying to decide whether a given function is or

More information