- Syntax Directed Translation
- L19-Graphs.ppt
- Math 485
- MIT6_042JS10_quiz02
- Graf Theory - Exsercises and Problems
- Rumor Spreading Maximization and Source Identification in a Social Network
- se-2008-computer
- Mst
- hmk9
- Dot Guide
- Cost Element Cost Planning
- Descartes Rule of Signs Proof
- Algorithms
- MIT6_042JF10_assn02.pdf
- Graphs 1 Print
- Proofs Trees
- Data Types
- touringproblems[1]
- Domain and Range النطاق والمدى
- SDN
- Aptitude document for syntel
- Beyond the Shannon’s Bound
- B.Sc (Maths)
- Graph Theory Terms
- The Average Distance in a Random Graph
- graphAutomata-SeminarSlides-JanLeike.pdf
- (2006 Boccaletti Et Al) Complex Networks, Structure and Dynamics
- Greedy Techniques
- Unit 2 DAA
- D3 Tips and Tricks
- Sapiens: A Brief History of Humankind
- Yes Please
- The Unwinding: An Inner History of the New America
- The Innovators: How a Group of Hackers, Geniuses, and Geeks Created the Digital Revolution
- Elon Musk: Tesla, SpaceX, and the Quest for a Fantastic Future
- Dispatches from Pluto: Lost and Found in the Mississippi Delta
- John Adams
- Devil in the Grove: Thurgood Marshall, the Groveland Boys, and the Dawn of a New America
- The Prize: The Epic Quest for Oil, Money & Power
- This Changes Everything: Capitalism vs. The Climate
- Grand Pursuit: The Story of Economic Genius
- A Heartbreaking Work Of Staggering Genius: A Memoir Based on a True Story
- The Emperor of All Maladies: A Biography of Cancer
- Team of Rivals: The Political Genius of Abraham Lincoln
- The New Confessions of an Economic Hit Man
- Rise of ISIS: A Threat We Can't Ignore
- The Hard Thing About Hard Things: Building a Business When There Are No Easy Answers
- Smart People Should Build Things: How to Restore Our Culture of Achievement, Build a Path for Entrepreneurs, and Create New Jobs in America
- The World Is Flat 3.0: A Brief History of the Twenty-first Century
- Bad Feminist: Essays
- How To Win Friends and Influence People
- Steve Jobs
- Angela's Ashes: A Memoir
- The Silver Linings Playbook: A Novel
- Leaving Berlin: A Novel
- Extremely Loud and Incredibly Close: A Novel
- The Sympathizer: A Novel (Pulitzer Prize for Fiction)
- The Light Between Oceans: A Novel
- The Incarnations: A Novel
- You Too Can Have a Body Like Mine: A Novel
- Life of Pi
- The Love Affairs of Nathaniel P.: A Novel
- The Blazing World: A Novel
- The Rosie Project: A Novel
- The First Bad Man: A Novel
- We Are Not Ourselves: A Novel
- The Flamethrowers: A Novel
- Brooklyn: A Novel
- A Man Called Ove: A Novel
- The Master
- Bel Canto
- Interpreter of Maladies
- The Kitchen House: A Novel
- Beautiful Ruins: A Novel
- The Art of Racing in the Rain: A Novel
- Wolf Hall: A Novel
- The Wallcreeper
- A Prayer for Owen Meany: A Novel
- The Cider House Rules
- Lovers at the Chameleon Club, Paris 1932: A Novel
- The Bonfire of the Vanities: A Novel
- The Perks of Being a Wallflower
- The Constant Gardener: A Novel

This handout lists some sample problems that you should be able to solve as a pre-requisite to Computer 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 Computer Algorithms.

1

**Using Mathematical Induction
**

Given property P = P (n), prove that it holds for all integers n ≥ 0.

The task:

Base Case: Induction hypothesis: Induction step:

show that P (0) is correct; assume that for some ﬁxed, but arbitrary integer n ≥ 0, P holds for all integers 0, 1, . . . , n prove that the induction hypothesis, P (n), implies that P is true of n + 1: P (n) =⇒ P (n + 1) using the principle of Mathematical Induction conclude that P (n) is true for arbitrary n ≥ 0.

Conclusion:

Variants of induction: Strong Induction: Structural Induction:

(although they are really all the same thing) The induction step is instead: P (0) ∧ P (1) ∧ . . . ∧ P (n) =⇒ P (n + 1) 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). n2 − n . 12

Problem 1 Prove that for all n > 10 n−2<

1

Then P (n) =⇒ =⇒ =⇒ =⇒ =⇒ −n n − 2 < n 12 2 (n + 1) − 2 − 1 < (n+1) −(n+1)−2n−1+1 12 2 (n + 1) − 2 < (n+1) −(n+1)−2n−1+1 + 1 12 2 −(n+1) (n + 1) − 2 < (n+1) 12 − 2n + 1 12 2 −(n+1) (n + 1) − 2 < (n+1) 12 (since n > 10) 2 The last inequality is P (n + 1). we evaluate the right part of (1) n ( i=1 √ i) + √ √ √ n + 1 ≥ 2n n/3 + n + 1. i=1 i > 2n n/3. 2 ≥ ≥ (7) (8) 0 The last inequality holds true for any n > 0. i=1 Proof: We prove it by induction on n. 12 12 6 6 ∀k ≤ n (k > 10. given n ≥ 11. P holds true for all integers up n. Thus. 11 − 2 < 110 55 1 112 − 11 =⇒ 9 < = =9+ . 2 . For n = 1. and it does not change the principle. (2) The following sequence of equivalent inequalities completes the proof: √ √ √ 2n n/3 + n + 1 ≥ 2(n + 1) n + 1/3 √ √ √ 2n n + 3 n + 1 ≥ 2(n + 1) n + 1 √ √ 2n n ≥ (2n − 1) n + 1 4n2 n ≥ 4n 3 (3) (4) (5) (6) 3 (2n − 1)2 (n + 1) (4n − 4n + 1)(n + 1) = 4n − 3n + 1 −3n + 1. i=1 n+1 √ n i=( i=1 √ i) + √ n+1 (1) i=1 Using the given inequality. Suppose.Proof: Deﬁne property P (n) by P (n) : Then. n √ √ i > 2n n/3. k − 2 < k2 − k . Such a shift happens often. Base. Inductive step. 12 Notice that the base of the induction proof start with n = 11. since this is nothing more than the matter of notations. One can deﬁne a property Q(m) by Q(m) = P (n − 11). the left part is 1 and the right part is 2/3: 1 > 2/3. n > 10). Suppose the statement is correct for some n ≥ 1. Base case: for n = 11. rather than with n = 0. and consider Q for m ≥ 0. Induction step. we prove that it is correct for n + 1. √ √ n √ n+1 √ Given: Prove: i > 2(n + 1) n + 1/3. Problem 2 For every integer n ≥ 1.

we will show that this implies P (n + 1). The Inductive Hypothesis is that for all integers k such that 1 < k < n. Let A be an arbitrary set of n + 1 horses. Both of these are sets of n horses. . 6 Prove. .001 n(log2 n)15 3 . + F2n−1 = F2n . Proof: We will use strong induction. Thus. all horses in this set have the same color. f (n) (lg n)a 2n log2 n √ n n2 log2 n (1) (2) 34) (3) (4) (5) (6) log2 n 1000(log2 n)0. f (n) = Θ(g(n)). and the last n horses in A. or n can be written as n = n1 n2 with both n1 and n2 being integers greater than 1 and less than n. b > 0) 10n! (log2 n)5 (nlog2 n)4 log2 (66n) (log2 n)1. 2 Order of Functions See Chapter 2 of the textbook. f (n) = Ω(g(n)). either n is a prime itself (in which case it is a product of prime numbers). Thus. then all n + 1 horses of A must have the same color. since 2 itself is a prime. Inductive Step: The Inductive Hypothesis is that P (n) holds. Problem 4 Prove that every integer greater than 1 is a product of prime numbers. Consider the ﬁrst n horses in A. Problem 6 Prove by induction that F1 + F3 + .Problem 3 For every integer n ≥ 0. Base Case: P (1) is clearly true. Problem 7 Compare the following pairs of functions in terms of order of growth. n can be written as a product of prime numbers as well. the Inductive Hypothesis applies to both n1 and n2 . and the exercises therein. Then.999 n2 g(n) nb (here a. thus proving P (n + 1). Since the set of the ﬁrst n and the last n horses overlap. and so each can be written as a product of prime numbers. and so the inductive hypothesis holds for them. Prove your answers. where Fi denotes the ith Fibonacci number. we have that k can be written as a product of primes. Problem 5 What is wrong with the following classic “proof” that all horses have the same color? Let P (n) be the proposition that for any set of n horses. In each case. Inductive Step: Let n be an arbitrary integer greater than 1. telling us that both the ﬁrst n and the last n horses of A have the same color. determine if f (n) = O(g(n)). n i2 = i=0 n(n + 1)(2n + 1) . Base Case: 2 is a product of prime numbers.

. Inductive Step: Assume that P (w) is true for all children w of v. aw < av . n} to {1. Problem 11 Describe an algorithm (in words. then Tv consists of a single node v. 2. . Therefore.e. the resulting directed graph contains a rooted tree all of whose edges are directed away from the root. Problem 12 Show how to tell if graph is bipartite (in linear time). What is the complexity of your algorithm? Explain. aw is the largest label in Tw . directs its edges in such a way that the following two conditions are satisﬁed: 1. but graph G has a path from u to v and dis[u] < dis[v]. P (r) holds. m} is mn . Problem 14 How many nine digit numbers are there that contain exactly two 5’s? Problem 15 What are the coeﬃcients of the terms Explain. 2. show that in the case of a connected. . and so P (v) is trivially true. and so r has the largest label of all nodes in the tree. Base Case: If v is a leaf. Problem 17 Prove the following identities. av is the largest label in Tv . not a code). Proof: Let Tv be the subtree of T rooted at v. x2 1 in the expansion of (x + x )n . E). 2. . 4 . Prove that the root node r has the largest label of all nodes in the tree. . where (n > 2)? Problem 16 Prove that for every n ≥ 1 and every m ≥ 1. which for a given connected undirected graph G. Problem 8 Here is an example of Structural Induction in trees. every edge not in the tree above forms a directed cycle with some edges of the tree. Consider a rooted tree T = (V. its every edge is either a tree edge (belongs to the BFS tree). Assume that T obeys the heap property. undirected graph G. neither is a descendant of the other in the BFS tree. or a cross edge (connects two vertices.3 Graph Theory See also Chapter 3 of the textbook and the exercises therein. 4 Additional Problems in Discrete Math and Logic Problem 13 How many eight digit numbers are there that contain a 5 and a 6? Explain. as desired. We will prove the proposition P (v) which states that v has the largest label in Tv . and by the inductive hypothesis. Therefore. then aw < av . Problem 9 By analyzing the algorithm for Breadth-First-Search (BFS). the number of functions from {1.) Problem 10 Find an example of a directed graph and a DFS-forest such that vertex v is not a descendant of u. We have now shown that P (v) holds for all nodes v ∈ V . if w is a child of v. . 1 1 x . . . where nodes are labeled with positive integers: each node v ∈ V is labeled with an integer av .. By the heap property. i.

” Does the ﬁrst statement logically imply the second? Problem 19 (Contrapositive) Consider the following two statements: “100 percent of convicted felons consumed bread during their childhood.Idempotency Commutativity Associativity A ∪ A = A. A ∩ B = B ∩ A (A ∪ B) ∪ C = A ∪ (B ∪ C) (A ∩ B) ∩ C = A ∩ (B ∩ C) (A ∪ B) ∩ C = (A ∩ C) ∪ (B ∩ C) (A ∩ B) ∪ C = (A ∪ C) ∩ (B ∪ C) U − (B ∪ C) = (U − B) ∩ (U − C) U − (B ∩ C) = (U − B) ∪ (U − C) Distributivity DeMorgan’s Laws Problem 18 (Converse) Consider the following two statements: “100 percent of convicted felons consumed bread during their childhood.” Does the ﬁrst statement logically imply the second? Problem 20 Fill in the truth tables: P∧Q Q is true Q is false P is true P is false P∨Q Q is true Q is false P is true P is false If Q then P Q is true Q is false P is true P is false 5 . A ∩ A = A A ∪ B = B ∪ A.” and ”People who do not consume bread as a child do not become felons.” and ”People who consume bread as a child are likely to become felons.

- Syntax Directed TranslationUploaded byJoben Boben Senoc Montero
- L19-Graphs.pptUploaded bycatarac19
- Math 485Uploaded byJoona John
- MIT6_042JS10_quiz02Uploaded byasdf
- Graf Theory - Exsercises and ProblemsUploaded byLast Hope
- Rumor Spreading Maximization and Source Identification in a Social NetworkUploaded byGate RankOne
- se-2008-computerUploaded byapi-267035401
- MstUploaded bySzikinger Ďurica Armani
- hmk9Uploaded byRamin Melikov
- Dot GuideUploaded byfrawi31
- Cost Element Cost PlanningUploaded byBijaya Mahananda
- Descartes Rule of Signs ProofUploaded bySabyasachi Debnath
- AlgorithmsUploaded bySathyaprakash Hs
- MIT6_042JF10_assn02.pdfUploaded byMuhammad Naffah Amin
- Graphs 1 PrintUploaded byKarthik Shettyan
- Proofs TreesUploaded byOmar Arenas
- Data TypesUploaded byraviskumar2005
- touringproblems[1]Uploaded bySaiSpan
- Domain and Range النطاق والمدىUploaded bymaanibrahim
- SDNUploaded byHappy Gauba
- Aptitude document for syntelUploaded byVishal Vijay
- Beyond the Shannon’s BoundUploaded bySinshaw Bekele
- B.Sc (Maths)Uploaded byvrsafe
- Graph Theory TermsUploaded byAsif Iqbal Chhipa
- The Average Distance in a Random GraphUploaded byprem
- graphAutomata-SeminarSlides-JanLeike.pdfUploaded bybounken
- (2006 Boccaletti Et Al) Complex Networks, Structure and DynamicsUploaded bySergio Mario Chávez
- Greedy TechniquesUploaded bySiddhant Singh
- Unit 2 DAAUploaded bySatyanshu Srivastava
- D3 Tips and TricksUploaded byAbhishek Panchal