Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Math Review 1.

Slides:



Advertisements
Similar presentations
Proof Techniques and Recursion. Proof Techniques Proof by induction –Step 1: Prove the base case –Step 2: Inductive hypothesis, assume theorem is true.
Advertisements

Data Structures, Spring 2004 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
Data Structures, Spring 2006 © L. Joskowicz 1 Data Structures – LECTURE 3 Recurrence equations Formulating recurrence equations Solving recurrence equations.
1 Data Structures A program solves a problem. A program solves a problem. A solution consists of: A solution consists of:  a way to organize the data.
Costas Busch - RPI1 Mathematical Preliminaries. Costas Busch - RPI2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Courtesy Costas Busch - RPI1 Mathematical Preliminaries.
Recurrences Part 3. Recursive Algorithms Recurrences are useful for analyzing recursive algorithms Recurrence – an equation or inequality that describes.
Module #1 - Logic 1 Based on Rosen, Discrete Mathematics & Its Applications. Prepared by (c) , Michael P. Frank. Modified By Mingwu Chen Induction.
1 Section 3.3 Mathematical Induction. 2 Technique used extensively to prove results about large variety of discrete objects Can only be used to prove.
Lecture , 3.1 Methods of Proof. Last time in 1.5 To prove theorems we use rules of inference such as: p, p  q, therefore, q NOT q, p  q, therefore.
Induction and recursion
Algorithm Design and Analysis (ADA)
1 CSCI 2400 section 3 Models of Computation Instructor: Costas Busch.
Methods of Proof & Proof Strategies
Induction and recursion
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Graph Algorithms Shortest-Path.
1 CS 201 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
Mathematics Review Exponents Logarithms Series Modular arithmetic Proofs.
Chapter 2 - Mathematical Review Functions
Mathematical Induction. F(1) = 1; F(n+1) = F(n) + (2n+1) for n≥ F(n) n F(n) =n 2 for all n ≥ 1 Prove it!
Discrete Maths Objective to introduce mathematical induction through examples , Semester 2, Mathematical Induction 1.
1 CE 221 Data Structures & Algorithms Chapter 1 Introduction Text: Read Weiss, §1.1 – 1.3 Izmir University of Economics.
Advance Data Structure and Algorithm COSC600 Dr. Yanggon Kim Chapter 1.
MATH 224 – Discrete Mathematics
Methods of Proof. This Lecture Now we have learnt the basics in logic. We are going to apply the logical rules in proving mathematical theorems. Direct.
Chapter 1 Introduction. Goals Why the choice of algorithms is so critical when dealing with large inputs Basic mathematical background Review of Recursion.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Course Review Midterm.
CSC201 Analysis and Design of Algorithms Asst.Proof.Dr.Surasak Mungsing Oct-151 Lecture 2: Definition of algorithm and Mathematical.
Methods of Proofs PREDICATE LOGIC The “Quantifiers” and are known as predicate quantifiers. " means for all and means there exists. Example 1: If we.
1 Introduction to Abstract Mathematics Chapter 3: Elementary Number Theory and Methods of Proofs Instructor: Hayk Melikya Direct.
1 Sections 1.5 & 3.1 Methods of Proof / Proof Strategy.
Methods of Proof Lecture 3: Sep 9. This Lecture Now we have learnt the basics in logic. We are going to apply the logical rules in proving mathematical.
Mathematical Preliminaries. Sets Functions Relations Graphs Proof Techniques.
Theorems and conjectures
Discrete Maths: Induction/1 1 Discrete Maths Objective – –to introduce mathematical induction through examples , Semester
Recursion. What is recursion? Rules of recursion Mathematical induction The Fibonacci sequence Summary Outline.
Fall 2005Costas Busch - RPI1 Mathematical Preliminaries.
Mathematical Background and Linked Lists. 2 Iterative Algorithm for Sum Find the sum of the first n integers stored in an array v : sum (v[], n) temp_sum.
Prof. Busch - LSU1 Mathematical Preliminaries. Prof. Busch - LSU2 Mathematical Preliminaries Sets Functions Relations Graphs Proof Techniques.
Reading and Writing Mathematical Proofs Spring 2015 Lecture 4: Beyond Basic Induction.
Proofs, Induction and Recursion Basic Proof Techniques Mathematical Induction Recursive Functions and Recurrence Relations.
Chap 3 –A theorem is a statement that can be shown to be true –A proof is a sequence of statements to show that a theorem is true –Axioms: statements which.
Cpt S 223 – Advanced Data Structures Math Review 2
Halting Problem and TSP Wednesday, Week 8. Background - Halting Problem Common error: Program goes into an infinite loop. Wouldn’t it be nice to have.
Chapter 1: Introduction
Foundations of Discrete Mathematics Chapters 5 By Dr. Dalia M. Gil, Ph.D.
October 3, 2001CSE 373, Autumn Mathematical Background Exponents X A X B = X A+B X A / X B = X A-B (X A ) B = X AB X N +X N = 2X N 2 N +2 N = 2 N+1.
Mathematical Induction Section 5.1. Climbing an Infinite Ladder Suppose we have an infinite ladder: 1.We can reach the first rung of the ladder. 2.If.
A Different Solution  alternatively we can use the following algorithm: 1. if n == 0 done, otherwise I. print the string once II. print the string (n.
1 Mathematical Preliminaries. 2 Sets Functions Relations Graphs Proof Techniques.
Divide and Conquer Faculty Name: Ruhi Fatima Topics Covered Divide and Conquer Matrix multiplication Recurrence.
CS104:Discrete Structures Chapter 2: Proof Techniques.
1 CMSC 341 Math Review. 2 Exponents Identities (X A ) B = X AB X A * X B = X A+B X A / X B = X A-B X A + X B  X A+B.
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Methods of Proof Lecture 4: Sep 20 (chapter 3 of the book, except 3.5 and 3.8)
6/12/2016 Prepared by Dr.Saad Alabbad1 CS100 : Discrete Structures Proof Techniques(2) Mathematical Induction & Recursion Dr.Saad Alabbad Department of.
Section Recursion 2  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
Section Recursion  Recursion – defining an object (or function, algorithm, etc.) in terms of itself.  Recursion can be used to define sequences.
1 Proofs by Counterexample & Contradiction There are several ways to prove a theorem:  Counterexample: By providing an example of in which the theorem.
Hubert Chan (Chapters 1.6, 1.7, 4.1)
11.7 – Proof by Mathematical Induction
CS 3343: Analysis of Algorithms
CS2210:0001Discrete Structures Induction and Recursion
Hubert Chan (Chapters 1.6, 1.7, 4.1)
CSCI-2400 Models of Computation.
Applied Discrete Mathematics Week 9: Integer Properties
Mathematical Preliminaries
CMSC 341 Math Review.
CE 221 Data Structures & Algorithms Chapter 1 Introduction
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Presentation transcript:

Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 223 – Advanced Data Structures Math Review 1

Topics Proof techniques  Proof by induction  Proof by counterexample  Proof by contradiction Recursion Summary

Proof Techniques What do we want to prove?  Properties of a data structure always hold for all operations  Algorithm running time/memory usage will never exceed some limit  Algorithm will always be correct  Algorithm will always terminate

Proof by Induction Goal: Prove some hypothesis is true Three-step process  Prove the Base case: Show hypothesis is true for some initial conditions This step is almost always trivial  Inductive hypothesis: Assume hypothesis is true for all values ≤ k  Using the inductive hypothesis, show that the theorem is true for the next value, typically k + 1

Induction Example Prove arithmetic series (Step 1) Base case: Show true for N=1

Induction Example (cont’d) (Step 2) Assume true for N=k (Step 3) Show true for N=k+1

More Induction Examples Prove the geometric series Prove that the number of nodes N in a complete binary tree of depth D is 2 D+1 -1 Prove that

Proof by Counterexample Prove hypothesis is not true by giving an example that doesn’t work  Example: 2 N > N 2 ?  Example: Prove or disprove “all prime numbers are odd numbers” Proof by example? Proof by lots of examples? Proof by all possible examples?  Empirical proof  Hard when input size and contents can vary arbitrarily

Another Example Traveling salesman problem  Given N cities and costs for traveling between each pair of cities, find the least-cost tour to visit each city exactly once Hypothesis  Given a least-cost tour for N cities, the same tour will be least- cost for (N-1) cities  e.g., if A  B  C  D is the least-cost tour for cities {A,B,C,D}, then A  B  C will be the least-cost tour for cities {A,B,C} A DC B

Another Example (cont’d) Counterexample  Cost (A  B  C  D) = 40 (optimal)  Cost (A  B  C) = 30  Cost (A  C  B) = 20 A DC B

Proof by Contradiction Assume hypothesis is false Show this assumption leads to a contradiction (i.e., some known property is violated)  Can’t use special cases or specific examples Therefore, hypothesis must be true

Contradiction Example Variant of traveling salesman problem  Given N cities and costs for traveling between each pair of cities, find the least-cost path to go from city X to city Y Hypothesis  A least-cost path from X to Y contains least-cost paths from X to every city on the path  E.g., if X  C1  C2  C3  Y is the least-cost path from X to Y, then X  C1  C2  C3 is the least-cost path from X to C3 X  C1  C2 is the least-cost path from X to C2 X  C1 is the least-cost path from X to C1 A DC B

Contradiction Example (cont’d) Assume hypothesis is false  i.e., Given a least-cost path P from X to Y that goes through C, there is a better path P’ from X to C than the one in P Show a contradiction  But we could replace the subpath from X to C in P with this lesser- cost path P’  The path cost from C to Y is the same  Thus we now have a better path from X to Y  But this violates the assumption that P is the least-cost path from X to Y Therefore, the original hypothesis must be true X C Y P’

More Contradiction Example Example: Prove that the square root of 2 is irrational (a number that cannot be expressed as a fraction a/b, where a and b are integers, b  0) Proof: will be derived in the class  assume root of 2 is a rational number  assume a/b is simplified to the lowest terms can be done with any fraction in order for a/b to be in its simplest terms, both a and b must be not be even. One or both must be odd. Otherwise, you could simplify

Recursion A recursive function is defined in terms of itself Examples of recursive functions  Factorial  Fibonacci Factorial (n) if n = 0 then return 1 else return (n * Factorial (n-1))

Example Fibonacci numbers  F(0) = 0  F(1) = 1  F(2) = 1  F(3) = 2  F(4) = 3  F(5) = 5   F(n) = F(n-1) + F(n-2) Fibonacci (n) if (n ≤ 1) then return 1 else return (Fibonacci (n-1) + Fibonacci (n-2))

Basic Rules of Recursion Base cases  Must always have some base cases, which can be solved without recursion Making progress  Recursive calls must always make progress toward a base case Design rule  Assume that all the recursive calls work Compound interest rule  Never duplicate work by solving the same instance of a problem in separate recursive calls

Example (cont’d) Fibonacci (5) The Fibonacci numbers are the numbers in the following integer sequence:  0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144………… F(5) F(4) F(3) F(2) F(1) F(3) F(2) F(1) F(0) F(1)

Summary Proofs by mathematical induction, counterexample and contradiction Recursion Tools to help us analyze the performance of our data structures and algorithms Next Class:  Floors, ceilings, exponents, logarithms, series, and modular arithmetic

Questions ?