Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order?

Similar documents
CS103 Handout 08 Spring 2012 April 20, 2012 Problem Set 3

Checkpoint Questions Due Monday, October 1 at 2:15 PM Remaining Questions Due Friday, October 5 at 2:15 PM

Discrete Mathematics. Spring 2017

Induction and recursion. Chapter 5

Practice Second Midterm Exam I

Chapter Summary. Mathematical Induction Strong Induction Well-Ordering Recursive Definitions Structural Induction Recursive Algorithms

CS173 Lecture B, September 10, 2015

1 Sequences and Summation

Lecture Notes on DISCRETE MATHEMATICS. Eusebius Doedel

Complexity Theory VU , SS The Polynomial Hierarchy. Reinhard Pichler

Outline. Complexity Theory EXACT TSP. The Class DP. Definition. Problem EXACT TSP. Complexity of EXACT TSP. Proposition VU 181.

Math 38: Graph Theory Spring 2004 Dartmouth College. On Writing Proofs. 1 Introduction. 2 Finding A Solution

Announcements. Problem Set 1 out. Checkpoint due Monday, September 30. Remaining problems due Friday, October 4.

CS1800: Mathematical Induction. Professor Kevin Gold

Induction and Recursion

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

Discrete Mathematics and Probability Theory Fall 2013 Vazirani Note 1

In-Class Soln 1. CS 361, Lecture 4. Today s Outline. In-Class Soln 2

About This Document. MTH299 - Examples Weeks 1-6; updated on January 5, 2018

Department of Computer Science University at Albany, State University of New York Solutions to Sample Discrete Mathematics Examination II (Fall 2007)

Geometric Steiner Trees

3 Finite continued fractions

Mathematical Induction

Proof Techniques (Review of Math 271)

CPSC 121: Models of Computation. Module 9: Proof Techniques (part 2) Mathematical Induction

9/5/17. Fermat s last theorem. CS 220: Discrete Structures and their Applications. Proofs sections in zybooks. Proofs.

Midterm Exam. CS 3110: Design and Analysis of Algorithms. June 20, Group 1 Group 2 Group 3

Climbing an Infinite Ladder

Midterm 1. Your Exam Room: Name of Person Sitting on Your Left: Name of Person Sitting on Your Right: Name of Person Sitting in Front of You:

1 Implication and induction

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 3

MAS114: Solutions to Exercises

Discrete Mathematics for CS Fall 2003 Wagner Lecture 3. Strong induction

SEQUENCES, MATHEMATICAL INDUCTION, AND RECURSION

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

Homework 3: Solutions

Mathematical Induction

Math /Foundations of Algebra/Fall 2017 Foundations of the Foundations: Proofs

CITS2211 Discrete Structures (2017) Cardinality and Countability

With Question/Answer Animations

CS 173: Induction. Madhusudan Parthasarathy University of Illinois at Urbana-Champaign. February 7, 2016

EECS 1028 M: Discrete Mathematics for Engineers

Final Exam Review. 2. Let A = {, { }}. What is the cardinality of A? Is

5 Set Operations, Functions, and Counting

LECTURE NOTES DISCRETE MATHEMATICS. Eusebius Doedel

Lecture Notes 1 Basic Concepts of Mathematics MATH 352

Discrete Mathematics. Spring 2017

A Note on Turing Machine Design

CS103 Handout 12 Winter February 4, 2013 Practice Midterm Exam

Mathematical Fundamentals

The following techniques for methods of proofs are discussed in our text: - Vacuous proof - Trivial proof

CS103 Handout 09 Fall 2012 October 19, 2012 Problem Set 4

Loop Convergence. CS 536: Science of Programming, Fall 2018

What can you prove by induction?

COMP 182 Algorithmic Thinking. Proofs. Luay Nakhleh Computer Science Rice University

Notes on induction proofs and recursive definitions

CSE 2001: Introduction to Theory of Computation Fall Suprakash Datta

2 Lecture 2: Logical statements and proof by contradiction Lecture 10: More on Permutations, Group Homomorphisms 31

Mathematical Induction

MAT115A-21 COMPLETE LECTURE NOTES

Chapter 2. Mathematical Reasoning. 2.1 Mathematical Models

NATIONAL UNIVERSITY OF SINGAPORE CS3230 DESIGN AND ANALYSIS OF ALGORITHMS SEMESTER II: Time Allowed 2 Hours

ASSIGNMENT 1 SOLUTIONS

For all For every For each For any There exists at least one There exists There is Some

CS103 Handout 21 Winter 2016 February 3, 2016 Practice Midterm Exam

CMPSCI 250: Introduction to Computation. Lecture 11: Proof Techniques David Mix Barrington 5 March 2013

More Asymptotic Analysis Spring 2018 Discussion 8: March 6, 2018

Mathematics E-15 Seminar on Limits Suggested Lesson Topics

NP and Computational Intractability

CSI Mathematical Induction. Many statements assert that a property of the form P(n) is true for all integers n.

CS 4407 Algorithms Lecture: Shortest Path Algorithms

Proving simple set properties...

Algorithms and Data Structures 2016 Week 5 solutions (Tues 9th - Fri 12th February)

Graph Theory. Thomas Bloom. February 6, 2015

CS 220: Discrete Structures and their Applications. Mathematical Induction in zybooks

Trinity Web Site Design. Today we will learn about the technology of numbering systems.

The Inductive Proof Template

Notes for Math 290 using Introduction to Mathematical Proofs by Charles E. Roberts, Jr.

MATH10040: Chapter 0 Mathematics, Logic and Reasoning

1 Continued Fractions

Proof Calculus for Partial Correctness

ICS141: Discrete Mathematics for Computer Science I

MAS114: Exercises. October 26, 2018

Lecture 2: Continued fractions, rational approximations

CSE 1400 Applied Discrete Mathematics Proofs

Practice Second Midterm Exam III

CSE373: Data Structures and Algorithms Lecture 2: Math Review; Algorithm Analysis. Hunter Zahn Summer 2016

2 Arithmetic. 2.1 Greatest common divisors. This chapter is about properties of the integers Z = {..., 2, 1, 0, 1, 2,...}.

Exam Practice Problems

PROBLEM SET 3: PROOF TECHNIQUES

CS173 Lecture B, November 3, 2015

MTH 299 In Class and Recitation Problems SUMMER 2016

Notes on State Minimization

Mathematical Logic Part Three

Notes on Continued Fractions for Math 4400

Dynamic Programming: Shortest Paths and DFA to Reg Exps

Chapter 1A -- Real Numbers. iff. Math Symbols: Sets of Numbers

means is a subset of. So we say A B for sets A and B if x A we have x B holds. BY CONTRAST, a S means that a is a member of S.

Math Circle: Recursion and Induction

Topic Contents. Factoring Methods. Unit 3: Factoring Methods. Finding the square root of a number

Transcription:

CS103 Handout 16 Fall 2011 November 4, 2011 Extra Practice Problems Many of you have expressed interest in additional practice problems to review the material from the first four weeks of CS103. This handout contains completely optional practice problems that explore proof techniques. Feel free to email us or stop by office hours if you have any questions, want to check your answers, or are curious to learn more about some of these problems. Problem One: Order Relations i. What three properties does a binary relation have to have to be a partial order? ii. Consider the power set P(A) of any set A. Prove that is a partial order over P(A). iii. Let be the divisibility relation. We write x y if x divides y; that is, there exists some integer k Z such that y = xk. Prove that is a partial order over N, but that it is not a partial order over Z. Problem Two: Rational and Irrational Numbers Recall that a real number r is called rational if there exists integers p, q Z such that p / q = r, q 0, and p and q have no common divisors other than 1 and -1. Consider the quadratic equation ax 2 + bx + c = 0, where a, b, and c are all odd. Prove that this quadratic equation has no rational solutions. (Hint: If there is a rational solution p / q, then p is either even or odd and q is either even or odd. What would happen in each case?) Problem Three: Fibonacci Numbers The Fibonacci sequence is a famous sequence of numbers defined recursively as follows: F 0 = 0 F 1 = 1 F n + 2 = F n + F n + 1 The first few terms of the series are 0, 1, 1, 2, 3, 5, 8, 13, n F i = F n +2 1 i. Prove that i=0 ii. The Leonardo numbers are a sequence of numbers defined as follows: L 0 = 1 L 1 = 1 L n + 2 = 1 + L n + L n + 1 Prove that L n = 2F n + 1 1.

Problem Four: Fibonacci Induction In an inductive proof, the inductive step typically works by assuming P(n) and using this to show P(n + 1). When dealing with Fibonacci numbers, though, this may be undesirable. In particular, since Fibonacci numbers are defined such that knowing F n and F n + 1 provides a value for F n + 2, it seems more appropriate to assume P(n) and P(n + 1) and then use that knowledge to show that P(n + 2) holds. Suppose you have a property P(n) such that: P(0), P(1), and n N. (P(n) P(n + 1) P(n + 2)) Prove, by induction, that n N. P(n). (Hint: Construct a property Q(n) such that you can prove n N. Q(n) by induction and such that if Q(n) is true for some natural number n, P(n) is also true for that natural number n.) Problem Five: Affine Induction Another generalization of induction called affine induction can be used to show that some property P(x) holds for any integer of the form an + b, where a, b Z and n N. Suppose you have a property P(n) such that: P(b) n N. (P(an + b) P(a(n + 1) + b)) Prove, by the principle of mathematical induction, that n N. P(an + b). (Hint: Construct a property Q(n) such that you can prove n N. Q(n) by induction and such that if Q(n) is true for some natural number n, P(n) is also true for that integer of the form an + b for natural number n) Problem Six: String Reversal The reverse of a string w is the string w R whose characters appear in the reverse order from the original. If the characters of w, in order, are w 1, w 2,, w n, then w R = w n w n 1 w 1. Consider the function REV : Σ* Σ* defined as follows: ϵ if w=ϵ REV ( w)={ a REV ( x) if w=xa for some x Σ Prove that REV(w) = w R for any w Σ*. (Hint: Proceed by induction on the length of the string)

Problem Seven: Fun with Sums n i= n(n+1) Using induction, we saw how to prove that i=1 2. This allows us to replace a sum with a much simpler formula. In this problem, you will do the same for several other sums. i. Find a simple formula for the sum of the first n odd natural numbers, then prove by induction that your formula is correct. Your formula should not contain a summation (either as a Σ or as a sum containing an ellipsis). ii. Find a simple formula for the sum of the first n even natural numbers, then prove by induction that your formula is correct. Remember that 0 is the first even natural number. Your formula should not contain a summation (either as a Σ or as a sum containing an ellipsis). iii. For either (i) or (ii), provide a justification for your answer without using induction. You don't need to provide a formal proof here; simply explain the intuition behind the result through some other means. Problem Eight: The Division Algorithm As we mentioned in lecture, the division algorithm states that for any integers a and b with b 0, there exist unique integers q and r such that a = qb + r and 0 r < b. In this problem, you'll use the well-ordering principle to prove that there always is at least one choice of q and r satisfying the above criteria. While you could do this by induction, instead you'll use the well-ordering principle. Hopefully this will give you a feel for how this proof technique feels in practice. i. Using the well-ordering principle, show that the set of natural numbers of the form a kb, where a kb 0, has a least element. (Hint: Remember that you need to show that this set is nonempty to show that it has a least element) ii. Let q be the value of k for which a kb attains its least value. Prove that if we let r = a qb, then 0 r < b.

Problem Nine: Order Homomorphisms Suppose that (A, < A ) and (B, < B ) are strictly-ordered sets. Recall that an order homomorphism is a function h : A B such that a 1, a 2. (a 1 < A a 2 h(a 1 ) < h(a 2 )) Two ordered sets (A, < A ) and (B, < B ) are homomorphic if there is a homomorphism from A to B. i. Suppose that (A, <A) is a strictly, totally-ordered set. If (A, < A ) is homomorphic to (B, < B ), does this guarantee that B is strictly, totally-ordered as well? If so, prove it. If not, find a counterexample. Suppose we relax our definition so that (A, A ) and (B, B ) are posets (that is, A and B are partial orders over A and B, respectively). We can define a homomorphism from A to B now as a function a 1, a 2. (a 1 A a 2 h(a 1 ) B h(a 2 )) ii. Prove that under this new definition, if A and B are any nonempty, totally-ordered sets, that A is homomorphic to B. Problem Ten: Proofs about Logic Recall that formulas in propositional logic are defined inductively as follows: S S For any variable p, p S If φ S, then φ S and (φ) S. If φ S and ψ S, then φ ψ, φ ψ, φ ψ, and φ ψ are all in S. This problem will ask you to use structural induction to prove properties of propositional logic. i. Using structural induction, prove that if φ is a propositional logic formula that does not contain, then φ contains an odd number of symbols. ii. Prove that if φ is an arbitrary propositional logic formula, then φ contains an odd number of symbols if and only if it contains an even number of 's. (Hint: Prove by induction that the length of a propositional logic formula can be written as 2n + 1 + k, where n is a natural number and k is the total number of 's in the formula) iii. Prove, using a truth table, that p q p q. iv. Using your result from (iii), prove that if φ is a formula in propositional logic, then there is a propositional logic formula φ' such that φ φ' and φ' does not contain any copies of the symbol.

Problem Eleven: Pigeonhole Fruit! i. Suppose that you are given a perfectly spherical grapefruit with five stickers on it. Prove that no matter where the stickers are, there is some way to cut the grapefruit perfectly in half such that some half has pieces of at least four of the stickers on it. ii. Using the generalized pigeonhole principle, show that if you have a grapefruit with 2n + 3 stickers on it, there is some way to cut the grapefruit perfectly in half such that some half has pieces of at least n + 3 of the stickers on it. Problem Twelve: Fun with Power Sets i. Prove that if P(A) = P(B), then A = B. ii. Prove that for any A with A 2, P(A) A A by finding an appropriate injective or surjective function between these two sets. Note that A may be infinite. iii. Prove that if A is finite, then P(A) = 2 A. Problem Thirteen: Binary Search The binary search algorithm is a famous algorithm for efficiently finding an element in a sorted array. Given as input a sorted array of values and some particular value, binary search works by looking at the middle element of the array. If the array element there is equal to the value to be searched for, the algorithm terminates. If the element there is larger than the element to search for, binary search discards the second half of the array and then repeats this process on the new array. Otherwise, the element in the middle is less than the element to search for, so binary search discards the first half of the array and repeats this process on the new array. Below is some Java code for binary search: public static boolean binarysearch(int[] arr, int key) { int left = 0; int right = arr.length; } while (left < right) { int mid = (left + right) / 2; if (arr[mid] == key) return true; else if (arr[mid] < key) left = mid + 1; else right = mid; } return false;

In this problem, you will prove that this code is correct (ignoring issues of integer overflow) by using the technique of loop invariants. In particular, you will use the following two loop invariants to prove that the function works correctly: left right If key exists in arr at some index i, then left i < right. You may assume that ints never overflow their values and that arr is sorted in ascending order. i. Prove that if these two loop invariants are always true, then binarysearch correctly returns whether key is contained in arr. ii. Prove, by induction, that these two loop invariants are true no matter how many times the loop executes. (Hint: You may want your induction hypothesis to take the form P(k) = If the loop executes at least k times, then after the completion of the kth iteration, the two properties hold. ) Problem Fourteen: k-edge-connectivity Recall from lecture that a tree is an undirected, connected graph with no cycles. We say that a tree is minimally connected, meaning that it's connected but that removing any edge would disconnect the graph. This can be generalized to k-edge-connectivity. We say that a graph is k-edge-connected if you can remove any set of k edges from the graph without disconnecting it. Under this terminology, for example, a tree would be a 0-edge-connected graph. Intuitively, you can think of k-edge-connectivity as a measure of the relative robustness of some sort of network. Imagine, for example, that you have the entire US highway network represented as a series of edges representing highways and nodes representing junctions. Suppose, for example, that the US highway system is 12-edge-connected. * This would mean that if there are fewer than 12 serious accidents at any one time, there is always some unblocked path you could take from any US city to any other US city. i. Prove that for any natural number n > 1, there is a 1-edge-connected graph with n nodes and n edges. ii. Prove that for any natural number n > 1, no graph with n nodes is (n 1)-edge connected. In other words, if someone wanted to attack your graph by cutting edges, they would never need to cut more than n 2 edges to ensure that they had disconnected the graph. * This is a hypothetical value; I actually don't know for what value of k the US highway system is k-edgeconnected. If you can track down this value or compute it explicitly, I would love to see what you come up with!

Problem Fifteen: Graph Radius and Diameter Given an undirected, connected graph G = (V, E), the distance between two nodes is the length of the shortest path between them (measured in numbers of nodes). We denote the distance between u and v as d(u, v). For example, in this graph: A B C D we have that d(a, B) = 1, d(e, D) = 3, and d(c, C) = 0. E F The eccentricity of a vertex in the graph (denoted e(v)) is the maximum distance that any node in the graph is from v. For example, in the above graph, we have that e(b) = 2, since every node is at distance at most two from B (with nodes D and F being as far away as possible), while e(c) = 3 (because d(c, F) = 3, and this is the node at the furthest distance from C). The radius of a graph (denoted rad(g)) is the smallest eccentricity of any of its vertices. The diameter of a graph (denoted diam(g)) is the largest eccentricity of any of its vertices. In the above graph, the radius of the graph is 2, since node B is at distance at most 2 from each other node in the graph, and there is no node that is closer to all others. The diameter of the graph is 4, since d(f, D) = 4 and this is the largest distance between any two nodes. Prove that diam(g) 2 rad(g). As a hint, think about what would happen if this were not the case and consider the nodes u and v in the graph such that e(u) = diam(g) and e(v) = rad(g). Problem Sixteen: Strongly Connected Components Revisited Given a directed graph G = (V, E), define the relation u v to mean v is reachable from u. A strongly connected component (SCC) in a directed graph is a nonempty set of nodes U in the graph with the following properties: For any u U and v U, u v and v u. For any u U and v V U, either u v or v u. As you proved in the first problem set, every node in a graph belongs to exactly one strongly connected component. Let SCC(G) be the set of strongly-connected components in G. We can consider a new graph G' = (SCC(G), E') where the nodes of the new graph are the stronglyconnected components of G, and the edge set E' is defined as follows: E' = { (U, V) u U. v V. (U V (u, v) E) }

In other words, there is an edge from the SCC U to the SCC V if U and V are distinct connected components and there is an edge from some node in U to some node in V. For example, given this graph (whose SCCs are outlined): The new graph G' would be constructed as follows: Prove that for any graph G, the corresponding graph G' is a DAG. (Hint: Proceed by contradiction. What would happen if there were a cycle in G'?) Problem Seventeen: Strongly Connected Components Revisited, Again Suppose that we modify the definition of strongly connected component as follows. Given a directed graph G = (V, E), let us called a strongly edged component is a collection of nodes with the following properties: For any u U and v U, (u, v) E and (v, u) E. For any u U and v V U, either (u, v) E or (v, u) E. That is, a strongly edged component is a set of nodes where every node is connected to each node in the strongly edged component, and for any other node in the graph, either that node is not connected by an edge to some node in the strongly edged component, or some node in the strongly edged component is not connected to that node. Is it true that for any graph G = (V, E), that every node belongs to exactly one strongly edged component? If so, prove it. If not, give a counterexample.