Week #7 – 7/9/11 October 2002 Prof. Marie desJardins

Slides:



Advertisements
Similar presentations
Fall 2002CMSC Discrete Structures1 If I told you once, it must be... Recursion.
Advertisements

Jessie Zhao Course page: 1.
Recursive Definitions and Structural Induction
Introduction to CS Theory Lecture 2 – Discrete Math Revision Piotr Faliszewski
Recursively Defined Functions
Week #10 – 28/30 October and 1 November 2002 Prof. Marie desJardins
Discrete Structures & Algorithms More on Methods of Proof / Mathematical Induction EECE 320 — UBC.
CSE115/ENGR160 Discrete Mathematics 04/12/11 Ming-Hsuan Yang UC Merced 1.
CSE115/ENGR160 Discrete Mathematics 04/03/12 Ming-Hsuan Yang UC Merced 1.
Recursive Definitions Rosen, 3.4. Recursive (or inductive) Definitions Sometimes easier to define an object in terms of itself. This process is called.
4/17/2017 Section 3.6 Program Correctness ch3.6.
Chapter Mathematical Induction
1 Section 3.4 Recursive Definitions. 2 Recursion Recursion is the process of defining an object in terms of itself Technique can be used to define sequences,
22C:19 Discrete Math Induction and Recursion Fall 2011 Sukumar Ghosh.
Induction and recursion
Discrete Mathematics Chapter 4 Induction and Recursion 大葉大學 資訊工程系 黃鈴玲 (Lingling Huang)
September1999 CMSC 203 / 0201 Fall 2002 Week #11 – 4/6/8 November 2002 Prof. Marie desJardins.
Induction and recursion
Chapter 4: Induction and Recursion
Chapter 3 (Part 3): Mathematical Reasoning, Induction & Recursion  Recursive Algorithms (3.5)  Program Correctness (3.6)
© by Kenneth H. Rosen, Discrete Mathematics & its Applications, Sixth Edition, Mc Graw-Hill, 2007 Chapter 4 (Part 3): Mathematical Reasoning, Induction.
Section 5.3. Section Summary Recursively Defined Functions Recursively Defined Sets and Structures Structural Induction.
INDUCTION AND RECURSION. PRINCIPLE OF MATHEMATICAL INDUCTION To prove that P(n) is true for all positive integers n, where P(n) is a propositional function,
4.3 Recursive Definitions and Structural Induction The PMI, 2PMI, and WOP are all valuable tools in proving the correctness of loops and of recursively.
Module #14: Recursion Rosen 5 th ed., §§ In this class, we will study recursion, one of the most important topics in computer science. In the last.
September1999 CMSC 203 / 0201 Fall 2002 Week #8 – 14/16 October 2002 Prof. Marie desJardins.
CS Discrete Mathematical Structures Mehdi Ghayoumi MSB rm 132 Ofc hr: Thur, 9:30-11:30a.
Lecture 3.4: Recursive Algorithms CS 250, Discrete Structures, Fall 2011 Nitesh Saxena *Adopted from previous lectures by Zeph Grunschlag.
Computer Science School of Computing Clemson University Discrete Math and Reasoning about Software Correctness Joseph E. Hollingsworth
September1999 CMSC 203 / 0201 Fall 2002 Week #9 – 21/23/25 October 2002 Prof. Marie desJardins.
Chapter 5: Sequences, Mathematical Induction, and Recursion 5.9 General Recursive Definitions and Structural Induction 1 Erickson.
4.3 Recursive Definitions and Structural Induction Sometimes it is difficult to define an object explicitly. However, it may be easy to define this object.
Chapter Mathematical Induction 4.2 Strong Induction and Well-Ordering 4.3 Recursive Definitions and Structural Induction 4.4 Recursive Algorithms.
Recursive Algorithms &
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.
Sequences and Summations Section 2.4. Section Summary Sequences. – Examples: Geometric Progression, Arithmetic Progression Recurrence Relations – Example:
September1999 CMSC 203 / 0201 Fall 2002 Week #1 – 28/30 August 2002 Prof. Marie desJardins.
September1999 CMSC 203 / 0201 Fall 2002 Week #13 – 18/20/22 November 2002 Prof. Marie desJardins.
ICS 253: Discrete Structures I Induction and Recursion King Fahd University of Petroleum & Minerals Information & Computer Science Department.
CS 103 Discrete Structures Lecture 13 Induction and Recursion (1)
September1999 CMSC 203 / 0201 Fall 2002 Week #15 – 2/4/6 December 2002 Prof. Marie desJardins.
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.
September1999 CMSC 203 / 0201 Fall 2002 Week #14 – 25/27 November 2002 Prof. Marie desJardins clip art courtesy of
CompSci 102 Discrete Math for Computer Science March 13, 2012 Prof. Rodger Slides modified from Rosen.
Chapter 5 With Question/Answer Animations 1. Chapter Summary Mathematical Induction - Sec 5.1 Strong Induction and Well-Ordering - Sec 5.2 Lecture 18.
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.
CSE 311 Foundations of Computing I Lecture 15 Strong Induction and Recursive Definitions Spring
CPS Today’s topics Programming Recursion Invariants Reading Great Ideas, p Brookshear, Section Upcoming Copyrights, patents, and.
Mathematical Induction And Recursion Discrete Math Team KS MATEMATIKA DISKRIT (DISCRETE MATHEMATICS ) 1.
Fall 2002CMSC Discrete Structures1 Chapter 3 Sequences Mathematical Induction Recursion Recursion.
Lecture 3.4: Recursive Algorithms CS 250, Discrete Structures, Fall 2015 Nitesh Saxena Adopted from previous lectures by Zeph Grunschlag.
Chapter 4: Induction and Recursion
Chapter 4 (Part 3): Mathematical Reasoning, Induction & Recursion
CSE15 Discrete Mathematics 04/12/17
Induction and Recursion
Recursively Defined Functions
Mathematical Induction Recursion
Lecture Outline for Recurrences
Week #5 – 23/25/27 September 2002 Prof. Marie desJardins
Week #3 – 9/11/13 September 2002 Prof. Marie desJardins
Week #6 – 30 September / 2/4 October 2002 Prof. Marie desJardins
Week #2 – 4/6 September 2002 Prof. Marie desJardins
Applied Discrete Mathematics Week 9: Integer Properties
CS 250, Discrete Structures, Fall 2015 Nitesh Saxena
Applied Discrete Mathematics Week 7: Computation
Math/CSE 1019: Discrete Mathematics for Computer Science Fall 2011
Chapter 4 (Part 2): Mathematical Reasoning, Induction & Recursion
Recursion.
Program Correctness an introduction.
Presentation transcript:

Week #7 – 7/9/11 October 2002 Prof. Marie desJardins CMSC 203 / 0201 Fall 2002 Week #7 – 7/9/11 October 2002 Prof. Marie desJardins

TOPICS Recursion Recursive and iterative algorithms Program correctness

MON 10/7 RECURSION (3.3)

Concepts/Vocabulary Recursive (a.k.a. inductive) function definitions Recursively defined sets Special sequences: Factorial F(0)=1, F(n) = F(n-1)(n) = n! Fibonacci numbers f0 = 0, f1 = 1, fn = fn-1 + fn-2 Strings *: Strings over alphabet  Empty string  String length l(s) String concatenation

Examples S1 = Even positive integers S2 = Even integers 2  S1; x+2  S1 if x  S1 S2 = Even integers 2  S2; x+2  S2 if x  S2; x-2  S2 if x  S2 Prove that S1 is the set of all even positive integers Every even positive integer is in S1… Every member of S1 is an even positive integer…

Examples II Exercise 3.3.5: Give a recursive definition of the sequence {an}, n = 1, 2, 3, … if (a) an = 6n (b) an = 2n + 1 (c) an = 10n (d) an = 5 Exercise 3.3.31: When does a string belong to the set A of bit strings defined recursively by    0x1  A if x  A, where  is the empty string?

Examples III Exercise 3.3.33: Use Exercise 29 [definition of wi] and mathematical induction to show that l(wi) = i  l(w), where w is a string and i is a nonnegative integer. Exercise 3.3.34: Show that (wR)I = (wi)R whenever w is a string and I is a nonnegative integer; that is, show that the ith power of the reversal of a string is the reversal of the ith power of the string.

WED 10/9 RECURSIVE ALGORITHMS (3.4) ** HOMEWORK #4 DUE ** ** UNGRADED QUIZ TODAY **

Concepts / Vocabulary Recursive algorithm Iterative algorithm

Examples Algorithm 7: Recursive Fibonacci Complexity of f7 (Exercise 14), fn Algorithm 8: Iterative Fibonacci Complexity f7 (Exercise 14), fn Eercise 3.4.23: Give a recursive algorithm for finding the reversal of a bit string.

FRI 10/11 PROGRAM CORRECTNESS (3.5)

Concepts / Vocabulary Initial assertion, final assertion Correctness, partial correctness, termination “Partially correct with respect to initial assertion p and final assertion q” Rules of inference Composition rule Conditional rules Loop invariants

Examples Exercise 3.5.3: Verify that the program segment x := 2 z := x + y if y > 0 then z := z + 1 else z := 0 is correct with respect to the initial assertion y=3 and the final assertion z=6.

Examples II Exercise 3.5.6: Use the rule of inference developed in Exercise 5 [if… else if … else …] to verify that the program if x < 0 then y := -2|x| / x else if x > 0 then y := 2|x| / x else if x = 0 then y := 2 is correct with respect to the initial assertion T and the final assertion y=2.