Recursion and Structural Induction
|
|
- Lorraine Elizabeth Dorsey
- 5 years ago
- Views:
Transcription
1 Recursion and Structural Induction Mukulika Ghosh Fall 2018 Based on slides by Dr. Hyunyoung Lee
2 Recursively Defined Functions Recursively Defined Functions Suppose we have a function with the set of non-negative integers as its domain. We can specify the function as follows: Basis step: Specify the value of the function at 0. Recursive or Inductive step: Give a rule for finding its value at an integer from its values at smaller integers. This is called a recursive or inductive definition. Mukulika Ghosh Parasol Lab - Texas A&M University 2/26
3 Recursively Defined Functions Examples Factorial We can define the factorial function n! as follows: Base step: 0! = 1 Recursive step: n! = n(n 1)! Fibonacci Numbers The Fibonacci numbers f n are defined as follows: Base step: f 0 = 0 and f 1 = 1 Recursive step: f n = f n 1 + f n 2 for n 2 Mukulika Ghosh Parasol Lab - Texas A&M University 3/26
4 Recursively Defined Functions One can define recursively defined functions for domains other than the non-negative integers. In general, a function f is called recursively defined if and only if at least one value f(x) is defined in terms of another value f(y), where x and y are distinct elements. Mukulika Ghosh Parasol Lab - Texas A&M University 4/26
5 Recursively Defined Functions Exercise Let F be the function such that F (n) is the sum of the first n positive integers. Give a recursive definition of F (n). Mukulika Ghosh Parasol Lab - Texas A&M University 5/26
6 Recursively Defined Sets Recursively Defined Sets An recursive definition of a set S has the following form: 1. Basis: Specify one or more initial elements of S. 2. Recursion/Induction: Give one or more rules for constructing new elements of S from old elements of S. 3. Closure: The set S consists of exactly the elements that can be obtained by starting with the initial elements of S and applying the rules for constructing new elements of S. Mukulika Ghosh Parasol Lab - Texas A&M University 6/26
7 Recursively Defined Sets The definition is similar to steps taken inductions. The closure condition is usually omitted, since it is always assumed in recursive definitions. Example: Natural numbers {0, 1, 2,...} can be defined as: Basis: 0 N Recursion: If n N then n + 1 N Mukulika Ghosh Parasol Lab - Texas A&M University 7/26
8 Why Recursive Definition Why Recursive Definition Recursive definition is popular in computer science. With recursive definition, there is no ambiguities about the contents of a set. Example Consider the set {0, 1, 3, 5, 7,...} can represent either set of odd primes or set of odd integers based on the contents so far. But a recursive definition: 0 S as basis and recursion as n + 2 S when n S remove such ambiguities. Mukulika Ghosh Parasol Lab - Texas A&M University 8/26
9 Another Example Another Example Let S be the set defined as follows: Basis: 0 S Recursion: If n S, then 2n + 1 S. The set can also be described as, S = {0, 1, 3, 7, 15, 31,...} = {2 n 1 n is a non-negative integer } since = 0 and 2 n+1 1 = 2(2 n 1) + 1 Mukulika Ghosh Parasol Lab - Texas A&M University 9/26
10 Exercise Exercise Give the recursive definition of the sequence {a n }, n = 1, 2, 3,... if a n = n 2 Mukulika Ghosh Parasol Lab - Texas A&M University 10/26
11 Applications: Well-formed Formulas Applications: Well-formed Formulas We can define the set of well-formed formulas consisting of variables, numerals, and operators from the set {+,,, /} as follows: Basis: x is a well-formed formula if x is a numeral or a variable. Recursion: If F and G are well-formed formulas, then (F + G), (F G), (F G), and (F/G) are well-formed formulas. Examples: 42, x, (x + 42), (x y), (3/0), (x (y + z)) Application: Definition of grammars, logic etc. Mukulika Ghosh Parasol Lab - Texas A&M University 11/26
12 Applications: Lists Applications: Lists We can define the set L of finite lists of integers as follows. Basis: The empty list () is contained in L Recursion: If i is an integer, and l is a list in L, then (cons i l) is in L. Note: This is the Lisp style of lists, where (cons i l) prepends the data item i at the front of the list l Example: (cons 1 (cons 2 (cons 3 () ))) is the list (1 2 3) in Lisp. Application: Data structure Mukulika Ghosh Parasol Lab - Texas A&M University 12/26
13 Applications: Binary Trees Applications: Binary Trees We can define the set B of binary trees over an alphabet A as follows: Basis: <> B. Recursion: If L, R B and x A, then < L, x, R > B. Example: <<>, 1, <>> is a tree with one node (1) Example: <<<>, 1, <>>, r, <<>, 2, <>>> is tree with root r and two children (1 and 2). Application: Data structure Mukulika Ghosh Parasol Lab - Texas A&M University 13/26
14 Structural Induction Structural Induction Structural induction asserts a property about elements of an inductively defined set. The proof method directly exploits the inductive definition of the set. The method is more powerful than strong induction in the sense that one can prove statements that are difficult (or impossible) to prove with strong induction. Typically, though, it is simply used because it is more convenient than (strong) induction. Mukulika Ghosh Parasol Lab - Texas A&M University 14/26
15 Structural Induction In structural induction, the proof of the assertion that every element of an inductively defined set S has a certain property P proceeds by showing that: Basis: Every element in the basis of the definition of S satisfies the property P. Induction: Assuming that every argument of a constructor has property P, show that the constructed element has the property P. Mukulika Ghosh Parasol Lab - Texas A&M University 15/26
16 Example: Binary Trees Example: Binary Trees The set B of binary trees over an alphabet A is defined as follows: Basis: <> B. Recursion: If L, R B and x A, then < L, x, R > B We can now prove that every binary tree has a property P by arguing that Basis: P (<>) is true. Induction: For all binary trees L and R and x A, if P (L) and P (R), then P (< L, x, R >) Mukulika Ghosh Parasol Lab - Texas A&M University 16/26
17 Example: Binary Trees Let f : B N be a function defined by: f(<>) = 0 1, if L = R =<> f(< L, x, R >) = f(l) + f(r), otherwise Let T in B be a binary tree. Then f(t ) yields the number of leaves of T. Mukulika Ghosh Parasol Lab - Texas A&M University 17/26
18 Example: Binary Trees Proof Basis: The empty tree has no leaves, so f(<>) = 0 is correct. Induction: Let L, R be trees in B, x A. Induction Hypothesis: Suppose that f(l) and f(r) denote the number of leaves of L and R, respectively. If L = R =<>, then < L, x, R >=<<>, x, <>> has one leaf, namely x, so f(< L, x, R >) = 1 is correct. If L and R are not both empty, then the number of leaves of the tree < L, x, R > is equal to the number of leaves of L and R. Hence, by induction hypothesis, we get f(< L, x, R >) = f(l) + f(r) as claimed. Mukulika Ghosh Parasol Lab - Texas A&M University 18/26
19 Example: Complete Binary Trees Example: Complete Binary Trees A binary tree is complete if and only if each node is either a leaf or has precisely two children. Recursive Definition Basis: There is a complete binary tree consisting of a single vertex r Recursion: If T 1 and T 2 are disjoint complete binary trees and r A is a node, then < T 1, r, T 2 > is a complete binary tree with root r and left subtree T 1 and right subtree T 2. The difference between binary trees and complete binary trees is in the basis step. Mukulika Ghosh Parasol Lab - Texas A&M University 19/26
20 Example: Complete Binary Trees Mukulika Ghosh Parasol Lab - Texas A&M University 20/26
21 Height of Complete Binary Tree Height of Complete Binary Tree Let T be a complete binary tree over an alphabet A. We define the height h(t ) of a complete binary tree as follows: Basis: For r A, we define h(r) = 0; that is, the height of a complete binary tree with just a single node is 0. Recursion: If L and R are complete binary trees and r A, then the tree < L, r, R > has height h(< L, r, R >) = 1 + max(h(l), h(r)) Mukulika Ghosh Parasol Lab - Texas A&M University 21/26
22 Number of Nodes in Complete Binary Tree Number of Nodes in Complete Binary Tree Let n(t ) denote the number of nodes of a complete binary tree over an alphabet A. Then Basis: For r A, we have n(r) = 1. Recursion: If L and R are complete binary trees and r A, then the number of nodes of < L, r, R > is given by n(< L, r, R >) = 1 + n(l) + n(r) Mukulika Ghosh Parasol Lab - Texas A&M University 22/26
23 Example of Structural Induction Example of Structural Induction Let T be a complete binary tree over an alphabet A. Then we have n(t ) 2 h(t )+1 1. Proof: Basis step: For r in A, we have n(r) = 1 and h(r) = 0, therefore, we have n(r) = 1 2 (0+1) 1 = 2 h(r)+1 1, as claimed. Mukulika Ghosh Parasol Lab - Texas A&M University 23/26
24 Example of Structural Induction Inductive step: Suppose that L and R are complete binary trees that satisfy n(l) 2 h(l)+1 1 and n(r) 2 h(r)+1 1. Then the tree T =< L, r, R > satisfies: n(t ) = 1 + n(l) + n(r) h(l) h(r)+1 1, by Induction Hypothesis 2max(2 h(l)+1, 2 h(r)+1 ) 1, since a + b 2max(a, b) = 2.2 max(h(l),h(r))+1 1 = 2.2 h(t ) 1 = 2 h(t )+1 1 Mukulika Ghosh Parasol Lab - Texas A&M University 24/26
25 Complete Binary Tree: Internal Vertices and Leaves Complete Binary Tree: Internal Vertices and Leaves The set of leaves and the set of internal vertices of a complete binary tree is defined recursively: Base: The root r is a leaf of the complete binary tree with exactly one vertex r. This tree has no internal vertices. Recursion: The set of leaves of the tree T =< L, r, R > is the union of the sets of leaves of L and of R. The internal vertices of T are the root r of T and the union of the set of internal vertices of L and the set of internal vertices of R. Mukulika Ghosh Parasol Lab - Texas A&M University 25/26
26 Exercise Exercise Let l(t ) be the number of leaves of a binary tree T, and i(t ), the number of internal vertices of T. Use structural induction to show that l(t ) = i(t )+1 holds for all complete binary trees. Mukulika Ghosh Parasol Lab - Texas A&M University 26/26
Sets. Mukulika Ghosh. Fall Based on slides by Dr. Hyunyoung Lee
Sets Mukulika Ghosh Fall 2018 Based on slides by Dr. Hyunyoung Lee Sets Sets A set is an unordered collection of objects, called elements, without duplication. We write a A to denote that a is an element
More informationRecursively Defined Functions
Section 5.3 Recursively Defined Functions Definition: A recursive or inductive definition of a function consists of two steps. BASIS STEP: Specify the value of the function at zero. RECURSIVE STEP: Give
More informationRecursion defining an object (or function, algorithm, etc.) in terms of itself. Recursion can be used to define sequences
Section 5.3 1 Recursion 2 Recursion Recursion defining an object (or function, algorithm, etc.) in terms of itself. Recursion can be used to define sequences Previously sequences were defined using a specific
More information1. Find f(1), f(2), f(3), and f(4) if f(n) is defined recursively by f(0) = 1 and for n = 0, 1, 2,
Exercises Exercises 1. Find f(1), f(2), f(3), and f(4) if f(n) is defined recursively by f(0) = 1 and for n = 0, 1, 2, a) f(n + 1) = f(n) + 2. b) f(n + 1) = 3f(n). c) f(n + 1) = 2f(n). d) f(n + 1) = f(n)2
More informationRecursive Definitions Structural Induction Recursive Algorithms
Chapter 4 1 4.3-4.4 Recursive Definitions Structural Induction Recursive Algorithms 2 Section 4.1 3 Principle of Mathematical Induction Principle of Mathematical Induction: To prove that P(n) is true for
More informationChapter Summary. Recursively defined Functions. Recursively defined sets and Structures Structural Induction
Section 5.3 1 Chapter Summary Recursively defined Functions. Recursively defined sets and Structures Structural Induction 5.3 Recursive definitions and structural induction A recursively defined picture
More informationLamé s Theorem. Strings. Recursively Defined Sets and Structures. Recursively Defined Sets and Structures
Lamé s Theorem Gabriel Lamé (1795-1870) Recursively Defined Sets and Structures Lamé s Theorem: Let a and b be positive integers with a b Then the number of divisions used by the Euclidian algorithm to
More informationMathematical Induction
COMP 182 Algorithmic Thinking Mathematical Induction Luay Nakhleh Computer Science Rice University Chapter 5, Section 1-4 Reading Material [P (1) ^8k(P (k)! P (k + 1))]!8nP (n) Why Is It Valid? The well-ordering
More information5 Graphs
5 Graphs jacques@ucsd.edu Some of the putnam problems are to do with graphs. They do not assume more than a basic familiarity with the definitions and terminology of graph theory. 5.1 Basic definitions
More informationIntroduction to Automata Theory. BİL405 - Automata Theory and Formal Languages 1
Introduction to Automata Theory BİL405 - Automata Theory and Formal Languages 1 Automata, Computability and Complexity Automata, Computability and Complexity are linked by the question: What are the fundamental
More information5.3 Recursive definitions and structural induction
Recall factorial function: n! = n (n-1) 1, for n 0 and 0! = 1 Then 4! = 4 3 2 1 = 24 5! = 5 4 3 2 1 = 120 1 Recall factorial function: f(n) = n! = n (n-1) 1, for n 0 and f(0) =0! = 1 Then f(4) = 4! = 4
More information1KOd17RMoURxjn2 CSE 20 DISCRETE MATH Fall
CSE 20 https://goo.gl/forms/1o 1KOd17RMoURxjn2 DISCRETE MATH Fall 2017 http://cseweb.ucsd.edu/classes/fa17/cse20-ab/ Today's learning goals Explain the steps in a proof by mathematical and/or structural
More informationRecursive Definitions and Structural Induction
Recursive Definitions and Structural Induction Introduction If it is difficult to define an object explicitly, it may be easy to define this object in terms of itself (i.e., the current term could be given
More informationTrees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington
Trees (Part 1, Theoretical) CSE 2320 Algorithms and Data Structures University of Texas at Arlington 1 Trees Trees are a natural data structure for representing specific data. Family trees. Organizational
More informationFoundations of Computer Science Spring Mathematical Preliminaries
Foundations of Computer Science Spring 2017 Equivalence Relation, Recursive Definition, and Mathematical Induction Mathematical Preliminaries Mohammad Ashiqur Rahman Department of Computer Science College
More informationWe will show that the height of a RB tree on n vertices is approximately 2*log n. In class I presented a simple structural proof of this claim:
We have seen that the insert operation on a RB takes an amount of time proportional to the number of the levels of the tree (since the additional operations required to do any rebalancing require constant
More informationHW Graph Theory SOLUTIONS (hbovik) - Q
1, Diestel 9.3: An arithmetic progression is an increasing sequence of numbers of the form a, a+d, a+ d, a + 3d.... Van der Waerden s theorem says that no matter how we partition the natural numbers into
More informationMath 485, Graph Theory: Homework #3
Math 485, Graph Theory: Homework #3 Stephen G Simpson Due Monday, October 26, 2009 The assignment consists of Exercises 2129, 2135, 2137, 2218, 238, 2310, 2313, 2314, 2315 in the West textbook, plus the
More informationSolution to Graded Problem Set 4
Graph Theory Applications EPFL, Spring 2014 Solution to Graded Problem Set 4 Date: 13.03.2014 Due by 18:00 20.03.2014 Problem 1. Let V be the set of vertices, x be the number of leaves in the tree and
More information1. Chapter 1, # 1: Prove that for all sets A, B, C, the formula
Homework 1 MTH 4590 Spring 2018 1. Chapter 1, # 1: Prove that for all sets,, C, the formula ( C) = ( ) ( C) is true. Proof : It suffices to show that ( C) ( ) ( C) and ( ) ( C) ( C). ssume that x ( C),
More informationMATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability)
MATHEMATICS 191, FALL 2004 MATHEMATICAL PROBABILITY Outline #1 (Countability and Uncountability) Last modified: September 16, 2004 Reference: Apostol, Calculus, Vol. 2, section 13.19 (attached). The aim
More informationTrees. 3. (Minimally Connected) G is connected and deleting any of its edges gives rise to a disconnected graph.
Trees 1 Introduction Trees are very special kind of (undirected) graphs. Formally speaking, a tree is a connected graph that is acyclic. 1 This definition has some drawbacks: given a graph it is not trivial
More informationChapter Summary. Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms
Chapter Summary Mathematical Induction Recursive Definitions Structural Induction Recursive Algorithms Section 5.1 Sec.on Summary Mathematical Induction Examples of Proof by Mathematical Induction Mistaken
More informationSlides for Faculty Oxford University Press All rights reserved.
Oxford University Press 2013 Slides for Faculty Assistance Preliminaries Author: Vivek Kulkarni vivek_kulkarni@yahoo.com Outline Following topics are covered in the slides: Basic concepts, namely, symbols,
More informationChapter 4: Trees. 4.2 For node B :
Chapter : Trees. (a) A. (b) G, H, I, L, M, and K.. For node B : (a) A. (b) D and E. (c) C. (d). (e).... There are N nodes. Each node has two pointers, so there are N pointers. Each node but the root has
More informationAnnouncements. CS243: Discrete Structures. Strong Induction and Recursively Defined Structures. Review. Example (review) Example (review), cont.
Announcements CS43: Discrete Structures Strong Induction and Recursively Defined Structures Işıl Dillig Homework 4 is due today Homework 5 is out today Covers induction (last lecture, this lecture, and
More informationCMPSCI 250: Introduction to Computation. Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013
CMPSCI 250: Introduction to Computation Lecture #14: Induction and Recursion (Still More Induction) David Mix Barrington 14 March 2013 Induction and Recursion Three Rules for Recursive Algorithms Proving
More informationPaths, Flowers and Vertex Cover
Paths, Flowers and Vertex Cover Venkatesh Raman, M.S. Ramanujan, and Saket Saurabh Presenting: Hen Sender 1 Introduction 2 Abstract. It is well known that in a bipartite (and more generally in a Konig)
More informationDO NOT RE-DISTRIBUTE THIS SOLUTION FILE
Professor Kindred Math 104, Graph Theory Homework 2 Solutions February 7, 2013 Introduction to Graph Theory, West Section 1.2: 26, 38, 42 Section 1.3: 14, 18 Section 2.1: 26, 29, 30 DO NOT RE-DISTRIBUTE
More informationDO NOT RE-DISTRIBUTE THIS SOLUTION FILE
Professor Kindred Math 104, Graph Theory Homework 3 Solutions February 14, 2013 Introduction to Graph Theory, West Section 2.1: 37, 62 Section 2.2: 6, 7, 15 Section 2.3: 7, 10, 14 DO NOT RE-DISTRIBUTE
More informationAnalysis of Algorithms
Analysis of Algorithms Concept Exam Code: 16 All questions are weighted equally. Assume worst case behavior and sufficiently large input sizes unless otherwise specified. Strong induction Consider this
More informationCOL351: Analysis and Design of Algorithms (CSE, IITD, Semester-I ) Name: Entry number:
Name: Entry number: There are 6 questions for a total of 75 points. 1. Consider functions f(n) = 10n2 n + 3 n and g(n) = n3 n. Answer the following: (a) ( 1 / 2 point) State true or false: f(n) is O(g(n)).
More informationGreedy Algorithms 1 {K(S) K(S) C} For large values of d, brute force search is not feasible because there are 2 d {1,..., d}.
Greedy Algorithms 1 Simple Knapsack Problem Greedy Algorithms form an important class of algorithmic techniques. We illustrate the idea by applying it to a simplified version of the Knapsack Problem. Informally,
More informationRecursion. Tjark Weber. Functional Programming 1. Based on notes by Sven-Olof Nyström. Tjark Weber (UU) Recursion 1 / 37
Tjark Weber Functional Programming 1 Based on notes by Sven-Olof Nyström Tjark Weber (UU) Recursion 1 / 37 Background FP I / Advanced FP FP I / Advanced FP This course (Functional Programming I) (5 hp,
More informationGraph Algorithms. Chromatic Polynomials. Graph Algorithms
Graph Algorithms Chromatic Polynomials Graph Algorithms Chromatic Polynomials Definition G a simple labelled graph with n vertices and m edges. k a positive integer. P G (k) number of different ways of
More informationDiscrete mathematics , Fall Instructor: prof. János Pach
Discrete mathematics 2016-2017, Fall Instructor: prof. János Pach - covered material - Lecture 1. Counting problems To read: [Lov]: 1.2. Sets, 1.3. Number of subsets, 1.5. Sequences, 1.6. Permutations,
More information1.3. Conditional expressions To express case distinctions like
Introduction Much of the theory developed in the underlying course Logic II can be implemented in a proof assistant. In the present setting this is interesting, since we can then machine extract from a
More informationWe assume uniform hashing (UH):
We assume uniform hashing (UH): the probe sequence of each key is equally likely to be any of the! permutations of 0,1,, 1 UH generalizes the notion of SUH that produces not just a single number, but a
More informationInference rule for Induction
Inference rule for Induction Let P( ) be a predicate with domain the positive integers BASE CASE INDUCTIVE STEP INDUCTIVE Step: Usually a direct proof Assume P(x) for arbitrary x (Inductive Hypothesis),
More informationProduct Cordial Sets of Trees
Product Cordial Sets of Trees Ebrahim Salehi, Seth Churchman, Tahj Hill, Jim Jordan Department of Mathematical Sciences University of Nevada, Las Vegas Las Vegas, NV 8954-42 ebrahim.salehi@unlv.edu Abstract
More informationCS525 Winter 2012 \ Class Assignment #2 Preparation
1 CS525 Winter 2012 \ Class Assignment #2 Preparation Ariel Stolerman 2.26) Let be a CFG in Chomsky Normal Form. Following is a proof that for any ( ) of length exactly steps are required for any derivation
More informationRecursive Data Structures and Grammars
Recursive Data Structures and Grammars Themes Recursive Description of Data Structures Grammars and Parsing Recursive Definitions of Properties of Data Structures Recursive Algorithms for Manipulating
More informationCS 173 [A]: Discrete Structures, Fall 2012 Homework 8 Solutions
CS 173 [A]: Discrete Structures, Fall 01 Homework 8 Solutions This homework contains 4 problems worth a total of 35 points. It is due on Wednesday, November 14th, at 5pm. 1 Induction Proofs With Inequalities
More informationRecursion. Lars-Henrik Eriksson. Functional Programming 1. Based on a presentation by Tjark Weber and notes by Sven-Olof Nyström
Lars-Henrik Eriksson Functional Programming 1 Based on a presentation by Tjark Weber and notes by Sven-Olof Nyström Tjark Weber (UU) Recursion 1 / 41 Comparison: Imperative/Functional Programming Comparison:
More informationExercise set 2 Solutions
Exercise set 2 Solutions Let H and H be the two components of T e and let F E(T ) consist of the edges of T with one endpoint in V (H), the other in V (H ) Since T is connected, F Furthermore, since T
More informationContext-Free Grammars
Context-Free Grammars 1 Informal Comments A context-free grammar is a notation for describing languages. It is more powerful than finite automata or RE s, but still cannot define all possible languages.
More informationCS 6783 (Applied Algorithms) Lecture 5
CS 6783 (Applied Algorithms) Lecture 5 Antonina Kolokolova January 19, 2012 1 Minimum Spanning Trees An undirected graph G is a pair (V, E); V is a set (of vertices or nodes); E is a set of (undirected)
More informationOutline. Introduction. 2 Proof of Correctness. 3 Final Notes. Precondition P 1 : Inputs include
Outline Computer Science 331 Correctness of Algorithms Mike Jacobson Department of Computer Science University of Calgary Lectures #2-4 1 What is a? Applications 2 Recursive Algorithms 3 Final Notes Additional
More information2009 HMMT Team Round. Writing proofs. Misha Lavrov. ARML Practice 3/2/2014
Writing proofs Misha Lavrov ARML Practice 3/2/2014 Warm-up / Review 1 (From my research) If x n = 2 1 x n 1 for n 2, solve for x n in terms of x 1. (For a more concrete problem, set x 1 = 2.) 2 (From this
More informationCIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018
CIS 121 Data Structures and Algorithms Midterm 3 Review Solution Sketches Fall 2018 Q1: Prove or disprove: You are given a connected undirected graph G = (V, E) with a weight function w defined over its
More informationEDAA40 At home exercises 1
EDAA40 At home exercises 1 1. Given, with as always the natural numbers starting at 1, let us define the following sets (with iff ): Give the number of elements in these sets as follows: 1. 23 2. 6 3.
More informationDefinition For vertices u, v V (G), the distance from u to v, denoted d(u, v), in G is the length of a shortest u, v-path. 1
Graph fundamentals Bipartite graph characterization Lemma. If a graph contains an odd closed walk, then it contains an odd cycle. Proof strategy: Consider a shortest closed odd walk W. If W is not a cycle,
More informationAlgorithms. AVL Tree
Algorithms AVL Tree Balanced binary tree The disadvantage of a binary search tree is that its height can be as large as N-1 This means that the time needed to perform insertion and deletion and many other
More informationFunctions 2/1/2017. Exercises. Exercises. Exercises. and the following mathematical appetizer is about. Functions. Functions
Exercises Question 1: Given a set A = {x, y, z} and a set B = {1, 2, 3, 4}, what is the value of 2 A 2 B? Answer: 2 A 2 B = 2 A 2 B = 2 A 2 B = 8 16 = 128 Exercises Question 2: Is it true for all sets
More informationTo illustrate what is intended the following are three write ups by students. Diagonalization
General guidelines: You may work with other people, as long as you write up your solution in your own words and understand everything you turn in. Make sure to justify your answers they should be clear
More information(a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are rational they can be written as the ratio of integers a 1
CS 70 Discrete Mathematics for CS Fall 2000 Wagner MT1 Sol Solutions to Midterm 1 1. (16 pts.) Theorems and proofs (a) (4 pts) Prove that if a and b are rational, then ab is rational. Since a and b are
More informationChapter 3: Propositional Languages
Chapter 3: Propositional Languages We define here a general notion of a propositional language. We show how to obtain, as specific cases, various languages for propositional classical logic and some non-classical
More informationMC 302 GRAPH THEORY 10/1/13 Solutions to HW #2 50 points + 6 XC points
MC 0 GRAPH THEORY 0// Solutions to HW # 0 points + XC points ) [CH] p.,..7. This problem introduces an important class of graphs called the hypercubes or k-cubes, Q, Q, Q, etc. I suggest that before you
More informationExercises: Disjoint Sets/ Union-find [updated Feb. 3]
Exercises: Disjoint Sets/ Union-find [updated Feb. 3] Questions 1) Suppose you have an implementation of union that is by-size and an implementation of find that does not use path compression. Give the
More informationThese notes present some properties of chordal graphs, a set of undirected graphs that are important for undirected graphical models.
Undirected Graphical Models: Chordal Graphs, Decomposable Graphs, Junction Trees, and Factorizations Peter Bartlett. October 2003. These notes present some properties of chordal graphs, a set of undirected
More informationCSE 20 DISCRETE MATH WINTER
CSE 20 DISCRETE MATH WINTER 2016 http://cseweb.ucsd.edu/classes/wi16/cse20-ab/ Today's learning goals Explain the steps in a proof by (strong) mathematical induction Use (strong) mathematical induction
More informationSolutions. (a) Claim: A d-ary tree of height h has at most 1 + d +...
Design and Analysis of Algorithms nd August, 016 Problem Sheet 1 Solutions Sushant Agarwal Solutions 1. A d-ary tree is a rooted tree in which each node has at most d children. Show that any d-ary tree
More informationSolutions to Homework 10
CS/Math 240: Intro to Discrete Math 5/3/20 Instructor: Dieter van Melkebeek Solutions to Homework 0 Problem There were five different languages in Problem 4 of Homework 9. The Language D 0 Recall that
More informationScribe: Virginia Williams, Sam Kim (2016), Mary Wootters (2017) Date: May 22, 2017
CS6 Lecture 4 Greedy Algorithms Scribe: Virginia Williams, Sam Kim (26), Mary Wootters (27) Date: May 22, 27 Greedy Algorithms Suppose we want to solve a problem, and we re able to come up with some recursive
More informationFebruary 24, :52 World Scientific Book - 9in x 6in soltys alg. Chapter 3. Greedy Algorithms
Chapter 3 Greedy Algorithms Greedy algorithms are algorithms prone to instant gratification. Without looking too far ahead, at each step they make a locally optimum choice, with the hope that it will lead
More information1. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which:
P R O B L E M S Finite Autom ata. Draw the state graphs for the finite automata which accept sets of strings composed of zeros and ones which: a) Are a multiple of three in length. b) End with the string
More informationLecture 1. 1 Notation
Lecture 1 (The material on mathematical logic is covered in the textbook starting with Chapter 5; however, for the first few lectures, I will be providing some required background topics and will not be
More informationFundamental mathematical techniques reviewed: Mathematical induction Recursion. Typically taught in courses such as Calculus and Discrete Mathematics.
Fundamental mathematical techniques reviewed: Mathematical induction Recursion Typically taught in courses such as Calculus and Discrete Mathematics. Techniques introduced: Divide-and-Conquer Algorithms
More informationAmbiguous Grammars and Compactification
Ambiguous Grammars and Compactification Mridul Aanjaneya Stanford University July 17, 2012 Mridul Aanjaneya Automata Theory 1/ 44 Midterm Review Mathematical Induction and Pigeonhole Principle Finite Automata
More informationGraph Theory Questions from Past Papers
Graph Theory Questions from Past Papers Bilkent University, Laurence Barker, 19 October 2017 Do not forget to justify your answers in terms which could be understood by people who know the background theory
More informationAXIOMS FOR THE INTEGERS
AXIOMS FOR THE INTEGERS BRIAN OSSERMAN We describe the set of axioms for the integers which we will use in the class. The axioms are almost the same as what is presented in Appendix A of the textbook,
More informationv V Question: How many edges are there in a graph with 10 vertices each of degree 6?
ECS20 Handout Graphs and Trees March 4, 2015 (updated 3/9) Notion of a graph 1. A graph G = (V,E) consists of V, a nonempty set of vertices (or nodes) and E, a set of pairs of elements of V called edges.
More informationMathematical Induction
Mathematical Induction Victor Adamchik Fall of 2005 Lecture 3 (out of three) Plan 1. Recursive Definitions 2. Recursively Defined Sets 3. Program Correctness Recursive Definitions Sometimes it is easier
More informationASSIGNMENT 4 SOLUTIONS
MATH 71 ASSIGNMENT SOLUTIONS 1. If F : X X is a function, define f (x) to be (f f)(x), and inductively define f k (x) (f f k 1 )(x) for each integer k. (So f (x) (f f )(x) f(f(f(x))) for instance.) We
More informationSolutions to Problem Set 1
CSCI-GA.3520-001 Honors Analysis of Algorithms Solutions to Problem Set 1 Problem 1 An O(n) algorithm that finds the kth integer in an array a = (a 1,..., a n ) of n distinct integers. Basic Idea Using
More information1 Maximum Independent Set
CS 408 Embeddings and MIS Abhiram Ranade In this lecture we will see another application of graph embedding. We will see that certain problems (e.g. maximum independent set, MIS) can be solved fast for
More information2 Geometry Solutions
2 Geometry Solutions jacques@ucsd.edu Here is give problems and solutions in increasing order of difficulty. 2.1 Easier problems Problem 1. What is the minimum number of hyperplanar slices to make a d-dimensional
More informationTrees. Q: Why study trees? A: Many advance ADTs are implemented using tree-based data structures.
Trees Q: Why study trees? : Many advance DTs are implemented using tree-based data structures. Recursive Definition of (Rooted) Tree: Let T be a set with n 0 elements. (i) If n = 0, T is an empty tree,
More informationNumber System. Introduction. Natural Numbers (N) Whole Numbers (W) Integers (Z) Prime Numbers (P) Face Value. Place Value
1 Number System Introduction In this chapter, we will study about the number system and number line. We will also learn about the four fundamental operations on whole numbers and their properties. Natural
More informationAssignment 4 Solutions of graph problems
Assignment 4 Solutions of graph problems 1. Let us assume that G is not a cycle. Consider the maximal path in the graph. Let the end points of the path be denoted as v 1, v k respectively. If either of
More informationProving Properties of Recursive Functions and Data Structures. CS 270 Math Foundations of CS Jeremy Johnson
Proving Properties of Recursive Functions and Data Structures CS 270 Math Foundations of CS Jeremy Johnson 1 Objective To implement and verify recursive functions for processing recursive data structures.
More informationCounting. Andreas Klappenecker
Counting Andreas Klappenecker Counting k = 0; for(int i=1; i
More informationPropositional Logic. Andreas Klappenecker
Propositional Logic Andreas Klappenecker Propositions A proposition is a declarative sentence that is either true or false (but not both). Examples: College Station is the capital of the USA. There are
More informationFall Recursion and induction. Stephen Brookes. Lecture 4
15-150 Fall 2018 Stephen Brookes Lecture 4 Recursion and induction Last time Specification format for a function F type assumption guarantee (REQUIRES) (ENSURES) For all (properly typed) x satisfying the
More informationProperties of red-black trees
Red-Black Trees Introduction We have seen that a binary search tree is a useful tool. I.e., if its height is h, then we can implement any basic operation on it in O(h) units of time. The problem: given
More informationFigure 4.1: The evolution of a rooted tree.
106 CHAPTER 4. INDUCTION, RECURSION AND RECURRENCES 4.6 Rooted Trees 4.6.1 The idea of a rooted tree We talked about how a tree diagram helps us visualize merge sort or other divide and conquer algorithms.
More informationGreedy Algorithms CHAPTER 16
CHAPTER 16 Greedy Algorithms In dynamic programming, the optimal solution is described in a recursive manner, and then is computed ``bottom up''. Dynamic programming is a powerful technique, but it often
More informationOutline. Definition. 2 Height-Balance. 3 Searches. 4 Rotations. 5 Insertion. 6 Deletions. 7 Reference. 1 Every node is either red or black.
Outline 1 Definition Computer Science 331 Red-Black rees Mike Jacobson Department of Computer Science University of Calgary Lectures #20-22 2 Height-Balance 3 Searches 4 Rotations 5 s: Main Case 6 Partial
More informationEvolution Module. 6.1 Phylogenetic Trees. Bob Gardner and Lev Yampolski. Integrated Biology and Discrete Math (IBMS 1300)
Evolution Module 6.1 Phylogenetic Trees Bob Gardner and Lev Yampolski Integrated Biology and Discrete Math (IBMS 1300) Fall 2008 1 INDUCTION Note. The natural numbers N is the familiar set N = {1, 2, 3,...}.
More informationTaibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103. Chapter 2. Sets
Taibah University College of Computer Science & Engineering Course Title: Discrete Mathematics Code: CS 103 Chapter 2 Sets Slides are adopted from Discrete Mathematics and It's Applications Kenneth H.
More informationRecursive definition of sets and structural induction
CS2209A 2017 Applied Logic for Computer Science Lecture 21, 22 Recursive definition of sets and structural induction Instructor: Marc Moreno Maza 1 Tower of Hanoi game Rules of the game: Start with all
More informationAssigning Meaning to Programs, Floyd. Proving Termination with Multiset Orderings
Assigning Meaning to Programs, Floyd Proving Termination with Multiset Orderings Well-founded Orderings Multiset Orderings Nested Multiset Orderings Consider the following program(turing s program): r=1,u=1
More informationTrees Rooted Trees Spanning trees and Shortest Paths. 12. Graphs and Trees 2. Aaron Tan November 2017
12. Graphs and Trees 2 Aaron Tan 6 10 November 2017 1 10.5 Trees 2 Definition Definition Definition: Tree A graph is said to be circuit-free if, and only if, it has no circuits. A graph is called a tree
More informationAn Annotated Language
Hoare Logic An Annotated Language State and Semantics Expressions are interpreted as functions from states to the corresponding domain of interpretation Operators have the obvious interpretation Free of
More informationGreedy Algorithms 1. For large values of d, brute force search is not feasible because there are 2 d
Greedy Algorithms 1 Simple Knapsack Problem Greedy Algorithms form an important class of algorithmic techniques. We illustrate the idea by applying it to a simplified version of the Knapsack Problem. Informally,
More informationOrganizing Spatial Data
Organizing Spatial Data Spatial data records include a sense of location as an attribute. Typically location is represented by coordinate data (in 2D or 3D). 1 If we are to search spatial data using the
More informationMATH 139 W12 Review 1 Checklist 1. Exam Checklist. 1. Introduction to Predicates and Quantified Statements (chapters ).
MATH 139 W12 Review 1 Checklist 1 Exam Checklist 1. Introduction to Predicates and Quantified Statements (chapters 3.1-3.4). universal and existential statements truth set negations of universal and existential
More informationWarmup Problem. Translate the following sentence from English into Propositional Logic. I want to eat ice cream even though I am on a diet.
Warmup Problem Translate the following sentence from English into Propositional Logic I want to eat ice cream even though I am on a diet 1/25 CS 245: Logic and Computation Carmen Bruni Lecture 2 Based
More informationDefinition: A graph G = (V, E) is called a tree if G is connected and acyclic. The following theorem captures many important facts about trees.
Tree 1. Trees and their Properties. Spanning trees 3. Minimum Spanning Trees 4. Applications of Minimum Spanning Trees 5. Minimum Spanning Tree Algorithms 1.1 Properties of Trees: Definition: A graph G
More informationComplexity Theory. Compiled By : Hari Prasad Pokhrel Page 1 of 20. ioenotes.edu.np
Chapter 1: Introduction Introduction Purpose of the Theory of Computation: Develop formal mathematical models of computation that reflect real-world computers. Nowadays, the Theory of Computation can be
More information