



Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Sample problems and solutions for mathematical induction and set operations, including using strong induction and structural induction, in the context of discrete mathematics. It covers topics such as proving properties for all integers, comparing functions in terms of order of growth, and analyzing algorithms for graph theory.
Typology: Study notes
1 / 5
This page cannot be seen from the preview
Don't miss anything!




This handout lists some sample problems that you should be able to solve as a pre-requisite to Design and Analysis of Algorithms. Try to solve all of them. You should also read Chapters 2 and 3 of the textbook, and look at the Exercises at the end of these chapters. If you are unfamiliar with some of these topics, or cannot solve many of these problems, then you should take a Discrete Math course before taking Design and Analysis of Algorithms.
The task: Given property P = P (n), prove that it holds for all integers n ≥ 0.
Base Case: show that P (0) is correct;
Induction assume that for some fixed, but arbitrary integer n ≥ 0, hypothesis: P holds for all integers 0, 1 ,... , n
Induction step: prove that the induction hypothesis, P (n), implies that P is true of n + 1: P (n) =⇒ P (n + 1)
Conclusion: using the principle of Mathematical Induction conclude that P (n) is true for arbitrary n ≥ 0.
Variants of induction: (although they are really all the same thing)
Strong Induction: The induction step is instead: P (0) ∧ P (1) ∧... ∧ P (n) =⇒ P (n + 1)
Structural Induction: We are given a set S with a well-ordering ≺ on the elements of this set. For example, the set S could be all the nodes in a tree, and the ordering is that v ≺ w if v is below w in the tree. The Base Case is now to show P (w) for all w ∈ S which have no element preceding it (i.e., such that there is no v ≺ w). The Inductive Step is now to show that for any w ∈ S, we have that (P (v) for all v ≺ w) =⇒ P (w).
Problem 1 Prove that for all n > 10
n − 2 <
n^2 − n 12
Proof: Define property P (n) by
P (n) : ∀k ≤ n (k > 10; n > 10), k − 2 <
k^2 − k 12
Then, Base case: for n = 11,
Notice that the base of the induction proof start with n = 11, rather than with n = 0. Such a shift happens often, and it does not change the principle, since this is nothing more than the matter of notations. One can define a property Q(m) by Q(m) = P (n − 11), and consider Q for m ≥ 0. Induction step. Suppose, given n ≥ 11, P holds true for all integers up n. Then
P (n) =⇒ n − 2 < n
(^2) −n 12 =⇒ (n + 1) − 2 − 1 < (n+1)
(^2) −(n+1)− 2 n−1+ 12 =⇒ (n + 1) − 2 < (n+1)
(^2) −(n+1)− 2 n−1+ 12 + 1 =⇒ (n + 1) − 2 < (n+1)
(^2) −(n+1) 12 −^
2 n 12 + 1 =⇒ (n + 1) − 2 < (n+1)
(^2) −(n+1) 12 (since^ n >^ 10) The last inequality is P (n + 1).
Problem 2 For every integer n ≥ 1 , ∑n
i=
i > 2 n
n/ 3.
Proof: We prove it by induction on n. Base. For n = 1, the left part is 1 and the right part is 2/3: 1 > 2 /3. Inductive step. Suppose the statement is correct for some n ≥ 1; we prove that it is correct for n + 1. Thus, Given:
∑n i=
i > 2 n
n/3; Prove:
∑n+ i=
i > 2(n + 1)
n + 1/3.
n∑+
i=
i = (
∑^ n
i=
i) +
n + 1 (1)
Using the given inequality, we evaluate the right part of (1)
∑^ n
i=
i) +
n + 1 ≥ 2 n
n/3 +
n + 1. (2)
The following sequence of equivalent inequalities completes the proof:
2 n
n/3 +
n + 1 ≥ 2(n + 1)
n + 1/ 3 (3) 2 n
n + 3
n + 1 ≥ 2(n + 1)
n + 1 (4) 2 n
n ≥ (2n − 1)
n + 1 (5) 4 n^2 n ≥ (2n − 1)^2 (n + 1) (6) 4 n^3 ≥ (4n^2 − 4 n + 1)(n + 1) = 4n^3 − 3 n + 1 (7) 0 ≥ − 3 n + 1. (8)
The last inequality holds true for any n > 0.
Problem 8 Here is an example of Structural Induction in trees. Consider a rooted tree T = (V, E), where nodes are labeled with positive integers: each node v ∈ V is labeled with an integer av. Assume that T obeys the heap property, i.e., if w is a child of v, then aw < av. Prove that the root node r has the largest label of all nodes in the tree.
Proof: Let Tv be the subtree of T rooted at v. We will prove the proposition P (v) which states that v has the largest label in Tv. Base Case: If v is a leaf, then Tv consists of a single node v, and so P (v) is trivially true. Inductive Step: Assume that P (w) is true for all children w of v. By the heap property, aw < av , and by the inductive hypothesis, aw is the largest label in Tw. Therefore, av is the largest label in Tv , as desired. We have now shown that P (v) holds for all nodes v ∈ V. Therefore, P (r) holds, and so r has the largest label of all nodes in the tree.
Problem 9
By analyzing the algorithm for Breadth-First-Search (BFS), show that in the case of a connected, undirected graph G, its every edge is either a tree edge (belongs to the BFS tree), or a cross edge (connects two vertices, neither is a descendant of the other in the BFS tree.)
Problem 10 Find an example of a directed graph and a DFS-forest such that vertex v is not a descendant of u, but graph G has a path from u to v and dis[u] < dis[v] (here dis[u] is the distance from the root).
Problem 11
Describe an algorithm (in words, not a code), which for a given connected undirected graph G, directs its edges in such a way that the following two conditions are satisfied:
What is the complexity of your algorithm? Explain.
Problem 12 Show how to tell if graph is bipartite (in linear time).
Problem 13 How many eight digit numbers are there that contain a 5 and a 6? Explain.
Problem 14 How many nine digit numbers are there that contain exactly two 5’s?
Problem 15 What are the coefficients of the terms (^1) x , (^) x^12 in the expansion of (x + (^) x^1 )n, where (n > 2)? Explain.
Problem 16 Prove that for every n ≥ 1 and every m ≥ 1 , the number of functions from { 1 , 2 ,... , n} to { 1 , 2 ,... , m} is mn.
Problem 17 Prove the following identities.
Idempotency A ∪ A = A; A ∩ A = A Commutativity A ∪ B = B ∪ A; A ∩ B = B ∩ A Associativity (A ∪ B) ∪ C = A ∪ (B ∪ C) (A ∩ B) ∩ C = A ∩ (B ∩ C) Distributivity (A ∪ B) ∩ C = (A ∩ C) ∪ (B ∩ C) (A ∩ B) ∪ C = (A ∪ C) ∩ (B ∪ C) DeMorgan’s Laws U − (B ∪ C) = (U − B) ∩ (U − C) U − (B ∩ C) = (U − B) ∪ (U − C)
Problem 18 (Converse) Consider the following two statements: “100 percent of convicted felons consumed bread during their childhood.” and ”People who consume bread as a child are likely to become felons.” Does the first statement logically imply the second?
Problem 19 (Contrapositive) Consider the following two statements: “100 percent of convicted felons con- sumed bread during their childhood.” and ”People who do not consume bread as a child do not become felons.” Does the first statement logically imply the second?