We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you!
Presentation is loading. Please wait.
Published byKarlee Pill
Modified over 2 years ago
Recursive Definitions & Structural Induction: Selected Exercises
Copyright © Peter Cappello2 Exercise 10 Give a recursive definition of S m ( n ), the sum of integer m + nonnegative integer n.
Copyright © Peter Cappello3 Exercise 10 Solution Give a recursive definition of S m ( n ), the sum of integer m + nonnegative integer n. S m ( n ) = ( n == 0 ) ? m : 1 + S m ( n – 1 );
Copyright © Peter Cappello4 Exercise 20 Give a recursive definition of the functions max & min so that max( a 1, a 2, …, a n ) & min( a 1, a 2, …, a n ) are the maximum & minimum of a 1, a 2, …, a n, respectively.
Copyright © Peter Cappello5 Exercise 20 Solution Give a recursive definition of the functions max & min so that max( a 1, a 2, …, a n ) & min( a 1, a 2, …, a n ) are the maximum & minimum of a 1, a 2, …, a n, respectively. max( a 1 ) = a 1 ; max( a 1, a 2 ) = (a 1 a 2 ) ? a 2 : a 1 ; (Why is this needed?) max( a 1, a 2, …, a n ) = max (max( a 1, a 2, …, a n-1 ), a n ) The min function is defined similarly.
Copyright © Peter Cappello6 Exercise 30 Prove that in any bit string, the string 01 occurs at most 1 more time than the string 10.
Copyright © Peter Cappello7 Exercise 30 Prove that in any bit string “01” occurs at most 1 more time than the “10”. Can we prove it by induction? Can we base the induction on the length of the bit string? If we –Show it’s true for | s | = 1 –Assume it’s true for | s | < n We try to show it’s true for | s | = n. –We break the string into bit string r = the 1 st n – 1 bits, followed by the last bit. –Apply the induction hypothesis to r. –Induction step: 4 cases, depending on the last bit of r &the last bit of s. –The case fails when the last bit of r is 1 & the last bit of s is 0. What to do?
Copyright © Peter Cappello8 Exercise 30 Proof 1.Basis: |s| = 1: #01(s) = 0 1 = #10(s) Assume: |s| < n #01(s) #10(s) Show: |s| = n #01(s) #10(s) + 1 (Decomposing s arbitrarily into 2 smaller strings, fails. Try it.) Case: s does not contain substring “10”: 1.It is of the form 0*1*. 2.#01(s) 1 = #10(s) + 1.
Copyright © Peter Cappello9 Case: s does contain substring “10”: Break s into 2 strings, t and u, between a “10” E.g., is broken into (100111)( ) 1. t ends in “1”; u begins with “0”. 2.#01(t) #10(t) + 1 (S.I.H.) 3.#01(u) #10(u) + 1 (S.I.H.) 4.#01(s) = #01(t) + #01(u) #10(t) + #10(u) + 2 = #10(s) + 1.
Copyright © Peter Cappello10 Exercise 40 To recursively define a set: 1.Define it to have some “initial” elements; 2.Give rules that compose new elements from pre- existing elements. Recursively define the set S of bit strings with more 0s than 1s.
Copyright © Peter Cappello11 Exercise 40 Solution Recursively define the set S of bit strings that have more 0s than 1s. 1.0 S. 2.x, y S xy, 1xy, x1y, xy1 S. This recursive definition of set S is like a context free grammar. S is a context-free language. These grammars & languages are studied in CMPSC 138. We use them to define the syntax of programming languages, like Java, C, & C++.
Copyright © Peter Cappello12
Copyright © Peter Cappello13 Exercise 50 Ackermann’s function is defined as follows: A( m, n ) = 2n, if m = 0; = 0, if m ≥ 1 n = 0 = 2, if m ≥ 1 n = 1 = A( m – 1, A( m, n – 1 ) ), if m ≥ 1 n ≥ 2. Show that A( 1, k ) = 2 k, for k ≥ 1. (We use structural induction.)
Copyright © Peter Cappello14 Exercise 50 Solution Ackermann’s function is defined as follows: A( m, n ) = 2n, if m = 0; = 0, if m ≥ 1 n = 0 = 2, if m ≥ 1 n = 1 = A( m – 1, A( m, n – 1 ) ), if m ≥ 1 n ≥ 2. Show that, for k ≥ 1, A( 1, k ) = 2 k. Basis k = 1: A( 1, 1 ) = 2 = 2 1. Show A( 1, k ) = 2 k A( 1, k + 1 ) = 2 k+1, for arbitrary k. Assume A( 1, k ) = 2 k. Prove A( 1, k + 1 ) = 2 k+1 : A( 1, k + 1) = A( 0, A(1, k ) ) = A( 0, 2 k ) = 2. 2 k = 2 k+1.
A Bijection between Z + & Rooted Trees The discussion below is based on Peter Cappello. A New Bijection between Natural Numbers and Rooted Trees. 4th SIAM Conf. on Discrete Mathematics, San Francisco, June 1988.A New Bijection between Natural Numbers and Rooted Trees Let P denote the set of primes numbers. Let T denote the set of rooted trees. Let p: Z +, P, where p(n) is the n th prime (e.g., p(4) = 7 and p -1 (7) = 4 ). p -1 (n) n. Copyright © Peter Cappello15
Generalized Permutations & Combinations: Selected Exercises.
The Pigeonhole Principle: Selected Exercises. Copyright © Peter Cappello2 The Pigeon-Hole Principle Let k be a positive integer. If k + 1 or more objects.
Recursive definitions. Capiche? Less is more Recursive Definitions 1. Specify a function at its lowest/minimum level (zero? One? Empty?) 2. Give a rule.
Mathematical Induction Rosen 3.3. Basics The Well-Ordering Property - Every nonempty set of nonnegative integers has a least element. Many theorems state.
Mathematical Induction. Mathematical Induction is a technique for proving theorems Theorems are typically of the form P(n) is true for all positive integers.
Analysis of Algorithms II The Recursive Case Except as otherwise noted, the content of this presentation is licensed under the Creative Commons Attribution.
With examples from Number Theory (Rosen 1.5, 3.1, sections on methods of proving theorems and fallacies)
Fall 2002CMSC Discrete Structures1 If I told you once, it must be... Recursion.
Countability. The cardinality of the set A is equal to the cardinality of a set B if there exists a bijection from A to B cardinality? bijection? injection.
Applications of Inclusion-Exclusion: Selected Exercises.
Discrete Mathematics Math 6A Homework A discrete mathematics class contains a mathematics major who is a freshman, 21 mathematics majors who.
Comp 122, Spring 2004 Order Statistics. order - 2 Lin / Devi Comp 122 Order Statistic i th order statistic: i th smallest element of a set of n elements.
Types and Programming Languages Lecture 4 Simon Gay Department of Computing Science University of Glasgow 2006/07.
5.1 Real Vector Spaces. Definition (1/2) Let V be an arbitrary nonempty set of objects on which two operations are defined, addition and multiplication.
Lecture 07: Theory of Automata:08 Properties of Regular Languages.
Jessie Zhao Course page: 1.
Fall 2002CMSC Discrete Structures1 Follow me for a walk through... MathematicalInduction.
Copyright © Cengage Learning. All rights reserved. 9 Sequences, Series, and Probability.
CS 336 March 19, 2012 Tandy Warnow. Basic Graph Terminology Nodes, vertices, edges, degrees, paths, cycles, connected components, adjacency, isolated.
Section 3.4 Objectives: Find function values Use the vertical line test Define increasing, decreasing and constant functions Interpret Domain and Range.
Lecture 1Discrete Structures 1 1 u Introduction to sets and set notation (5.1, 5.3) u Visualizing sets: Venn diagrams (5.1) u Axiom of extension (5.1)
: 1 Chapter 3. Growth of function Chapter 4. Recurrences.
Chapter 11 Trees Graphs III (Trees, MSTs) Reading: Epp Chp 11.5, 11.6.
Introduction to Proofs A proof is a valid argument that establishes the truth of a statement. Previous section discussed formal proofs Informal proofs.
Lecture 4 4.1,4.2 Counting. 4.1 Counting Two Important Principles: Product Rule and Sum Rule. Product Rule: Assume we need to perform procedure 1 AND.
Completeness and Expressiveness. Consistency: a syntactic definition, related to the proof system. A set of formulas is consistent if there is no formula.
Recognising Languages We will tackle the problem of defining languages by considering how we could recognise them. Problem: Is there a method of recognising.
Iterative Rounding and Iterative Relaxation Some of the slides prepared by Lap Chi Lau.
CS Section 600 CS Section 002 Dr. Angela Guercio Spring 2010.
1 Average Case Analysis of an Exact String Matching Algorithm Advisor: Professor R. C. T. Lee Speaker: S. C. Chen.
© 2016 SlidePlayer.com Inc. All rights reserved.