







Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!








10-2-08 Homework 3 CS 1050 A Due: 10-9-
Every assignment will be due at the beginning of class. Recall that you can collaborate in groups and/or use external references, but you must acknowledge the group/references that you used, and you must always write your solutions alone. Remember that for 90% of the people, more than 50% of the understanding happens during writing/implementation/etc. (And this is not true only for CS 1050. It is true for mostly everything, at least technical).
Please read the entire homework before starting to work on it. This homework (a)revisits ba- sic proof techniques (direct, contradiction, contrapositive) (b)refers to basic sums (c)addresses introductory aspects of recursion and induction. Please refer to the corresponding lecture outlines and assigned reading material. All are posted on the class website. You should definitely refer to the posted solutions for Homeworks 1, 2 and Quiz 1 to verify that you are complying with āappropriateā writing style for answering problems and questions. Re- peat: Just as you have to write ācodeā that others should be able to understand relatively easily (if you are software engineers), and just as you have to write āreportsā, or āessaysā, or āopinionsā that a reader should be able to easily āget the pointā (if you are managers, scientists, writers, bloggers etc), similarly you have to eventually be able to write ātechnical argumentsā so that convey to the reader relatively easily your sequence of thoughts.
Please stop by for questions during office hours of instructor or TAs and send email to [email protected] with title 1050 at any time. This helps you, but it also helps us! Sometimes it helps us understand where the class stands and where we should put more or less emphasis. And sometimes, you give us presentational and technical ideas that we would have not thought of otherwise. So keep all communication links open!
Please print this document, and write your solutions on the printout. Please hand-in the completed printout.
(a) Prove that there is no positive integer n such that n^2 + n^3 = 100. State clearly the steps of your proof, and state clearly the proof technique(s) that you are involving in each step.
(c) Prove that
3 is irrational. State clearly the proof technique that you are using.
In class and in the book we proved that 1 + 2 +... + n = n(n + 1)/2. In class and in the book we proved that, for any x = 1, 1 + x + x^2 +... + xn^ = x
n+1ā 1 xā 1.
(a1) Find a closed form for each of the sums below, and explain how you computed the closed form: 2 + 4 + 6 +... + 2n =? 1 + 3 + 5 +... + (2n + 1) =? 1 + 4 + 7 + 10 +... + (3n + 1) =? 1 + 2 + 2^2 + 2^3 +... + 2n^ =? 1 + 2^2 + 2^4 + 2^6 +... + 2^2 n^ =? (a2) Express each of the above sums in recusrive form. Write clearly the base of the recursion.
(b2) Using the definition of the log function, prove that: logy yx^ = x logy x 1 + logy x 2 = logy (x 1 Ā· x 2 ) logy(xn) = n logy x
logy x = log logzz^ xy
(a1) Suppose that N is any positive integer, and let a 1 , a 2 ,... , aN be a list of distinct numbers. Suppose that an algorithm finds the maximum number in the list, using comparisons only. Argue that, any such algorithm, must use at least N ā 1 comparisons. State clearly the involved invariant. (a2) Describe an algorithm that uses exactly N ā 1 comparisons.
(a) Prove, by induction, that for every positive integer n: 1 + 2^2 + 3^2 +... + n^2 = n(n+1)(2 6 n+1)
(b) Prove, by induction on n, that for every non-negative integer n: The solution to the recursion T (n) = 2T (n ā 1) + 1 with T (0) = 0 is T (n) = 2n^ ā 1. The solution to the recursion T (n) = T (n ā 1) + n with T (1) = 1 is T (n) = n(n + 1)/2.
(b) Use mathematical induction to show that, for every n ā„ 0, every complete binary tree with N = 2n^ leaves has exactly N ā 1 internal (non-leaf) nodes.