Docsity

CS 1050 A: Proof Techniques, Sums, Recursion and Induction Homework - Prof. Kolomira-Elini, Assignments of Computer Science

Toggle sidebar
bg1
10-2-08 Homework 3
CS 1050 A Due: 10-9-08
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
youused,andyoumustalways 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.
PRINT YOUR NAME HERE:........................................................... ...............................
WRITE YOUR EMAIL HERE:.......................................................... ................................
1
pf3
pf4
pf5
pf8
pf9
pfa
pfd

Partial preview of the text

Download CS 1050 A: Proof Techniques, Sums, Recursion and Induction Homework - Prof. Kolomira-Elini and more Assignments Computer Science in PDF only on Docsity!

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.

PRINT YOUR NAME HERE:........................................................... ...............................

WRITE YOUR EMAIL HERE:.......................................................... ................................

Problem 1: (20 points)

(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.

Problem 2: (20 points)

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

Problem 3: (20 points)

(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.

Problem 4: (20 points)

(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.