CS22/MATH2 Applied Discrete Math Fall 28 Instructor: Marc Pomplun Assignment # Sample Solutions Question : The Boston Powerlower Botanists at UMass Boston recently discovered a new local lower species that they named the Boston powerlower. It has beautiul, blue blossoms, and each plant lives or only one summer. During that time, each plant produces ten seeds. Two o these seeds will turn into plants in the ollowing year, and the remaining eight seeds will turn into lowers the year ater. As the name powerlower suggests, these seeds always turn into lower plants; there is no ailure ever. During the year o this discovery (let us call it year one), the scientists ound two powerlowers on the UMass campus, and in the ollowing year, there were already our o them. a) Devise a recurrence relation or the number o lower plants n in year n, and speciy the initial conditions. Recurrence relation: n 2n- +8n-2 Initial conditions: 2, 2 b) Use the above recurrence relation to predict the number o plants on the UMass campus in years,, 5, and 6. 22 +8 8 + 6 2 2 +82 8 + 2 8 5 2 +8 6 + 92 52 6 25 +8 7 + 6 c) Find an explicit ormula or computing the number o plants in any given year without requiring iteration, i.e., repeated application o a ormula. You should (but do not have to) check the correctness o your ormulas using some o the results you obtained in (b).
Characteristic equation: r 2 2r 8 Roots: r, r2-2 General solution: n α n + α2 (-2) n Given the initial conditions: I: 2 α - 2α2 II: 2 6α + α2 Computing 2 I + II: 8 2α α / Inserting into I: 2 / - 2α2 2α2 / - 2 α2 -/ Speciic solution: n n n n n Testing: 2 8 5 5 5 52 6 6 6 Well, looks good so ar
Question 2: Hilarious Numbers Let us deine that a positive integer is called hilarious i it has exactly three unique prime actors. For example, is hilarious, because its prime actors are 2,, and 5. Furthermore, 8 is also hilarious, because 8 2 2 7 and thus its unique prime actors are 2,, and 7. a) Write a program in Java, C, C++, Python, or pseudocode that inds the irst ive hilarious numbers. Attach a printout o your program to your assignment. Here is an example solution in C: int ishilarious(int n) int divisor, actors ; while (n > ) divisor 2; while (n % divisor! ) divisor++; while (n % divisor ) n / divisor; actors++; return (actors ); int main() int n 2, hilariouscount ; while (hilariouscount < 5) i (ishilarious(n)) print("%d\n", n); hilariouscount++; n++; return ; b) What are the irst ive hilarious numbers as discovered by your program? I you used pseudocode, you need to ind these numbers by hand. They are, 2, 6, 66, and 7.
Question : Prime Factor Examples Write down the prime actorization (in ascending order) o each o the ollowing integers (Example: 72 2 2 5). a) 677726 2 2 b) c) 255 5 7 d) 2 5 Question : Euclidean Algorithm Use the Euclidean algorithm to determine the ollowing greatest common divisors. Write down every step in your calculation. a) gcd(22, 22) 22 22 + 789 22 5 789 + 77 789 77 + 2 77 2 + 229 2 229 + 8 229 2 8 + 6 8 6 + 2 6 2 + 2 6 + 2 2 + 2 2 + gcd(22, 22) b) gcd(755, 855) 755 2 855 + 5 855 9 5 + gcd(755, 855) 5 c) gcd(62525, 625) 62525 625 + 25 625 25 25 + gcd(62525, 625) 25
Question 5: Induction Use mathematical induction to show that the ollowing equation is true or all natural numbers n: 2 + 2 + 2 2 + + 2 n 2 n+ - Basis step: For n we get 2 2 - true! Inductive step: Add 2 n+ to both sides: 2 + 2 + 2 2 + + 2 n + 2 n+ 2 n+ + 2 n+ 2 + 2 + 2 2 + + 2 n + 2 n+ 2 2 n+ 2 + 2 + 2 2 + + 2 n + 2 n+ 2 n+2 Thereore, the equation is true or all natural numbers n. Question 6: Counting How many o the ollowing things exist? Explain why. a) Strings o three hexadecimal digits, i digits can be repeated There are 6 choices or picking each digit, and we need to pick the digits one ater another to build the string, so according to the product rule there are 6 96 strings b) Strings o our octal digits, i digits cannot be repeated Here we are picking -permutations rom the set o 8 digits: P(8, ) 8!/! 8 7 6 5 68 c) Bit strings o length our with no substring (use tree diagram) There are 2 such strings:
d) Passwords consisting o two distinct English letters and three distinct decimal digits, where the letters are either in the irst two or the last two positions o the password. There are 26 distinct letters and distinct digits. Let us irst consider the case that the letters are in the irst two positions. Since we are looking or distinct letters and digits, the choices n or our ive picks are: n 26 25 9 8 68, In the case that the two letters occur in the last positions, the number n2 o choices is actually the same as n: n2 9 8 26 25 68, Since these two cases cannot occur at the same time, we can apply the sum rule: n n + n2 96,