CSE240 - Logic and Discrete Mathematics - Spring 2010 Homework 6 Solutions 1. (5 points) 2. (5 points) 3. (5 points) Due Monday, May 3rd 2010 58 points possible CSE240 - Logic and Discrete Mathematics - Spring 2010 Homework 6 Solutions 3. (continued) 4. (5 points) Due Monday, May 3rd 2010 58 points possible CSE240 - Logic and Discrete Mathematics - Spring 2010 Homework 6 Solutions Due Monday, May 3rd 2010 58 points possible 5. (10 points) ExpectedStepsToX = (probability x is 1st)*(steps to 1st element) + (prob. x is 2nd)*(steps to 2nd element) + ... + (prob. x is nth)*(steps to nth element) + (prob. x isn't in the array)*(steps needed to know this) = = = = = (p/n)*(1)+(p/n)*(2) + ... + (p/n)*(n) + (1-p)*(n) (p/n)*(1+2+3+...+n) + (1-p)*(n) (p/n)*[n*(n+1)/2] + (1-p)*(n) (p*n+p)/2 + (n - p*n) (2n + p - (p*n))/2 On average, [ (2n + p - (p*n)) / 2 ] comparisons will be made to either find x or to show that it isn’t present in the array. (Other forms of this expression are also acceptable) 6. (8 points) One type of mortgage is call variable mortgage, in which the monthly interest that the lender collects is at a low rate for a certain number of months initially, and then the interest will be locked into whatever the rate the central bank sets based on the financial market conditions. Assume that a borrower got a 30-year variable loan (meaning both the loan and interest need to be paid back within 30 years) of $100,000 at an initial monthly interest rate of 5% for the first 2 years, and then the monthly interest rate was locked into 6%. What is the total amount the borrower has to pay in total if the loan was exactly paid back in 30 years? a0 a30 = 100,000 = [ 100,000*(1+0.05/12)12*2 ]*(1+0.06/12)12*28 = (110494.13)*(1+0.06/12)12*28 = 590,385.89 Total paid: $590,385.89 Note: $1.026*1014 is also an acceptable answer, since the problem did not specify that the given interest rates were annual interest rates, compounded monthly. CSE240 - Logic and Discrete Mathematics - Spring 2010 Homework 6 Solutions 7. (10 points) Due Monday, May 3rd 2010 58 points possible CSE240 - Logic and Discrete Mathematics - Spring 2010 Homework 6 Solutions 8. (10 points) Due Monday, May 3rd 2010 58 points possible CSE240 - Logic and Discrete Mathematics - Spring 2010 Homework 6 Solutions Due Monday, May 3rd 2010 58 points possible 9. (10 points extra credit) (a) Combinatorial argument (5 points) Suppose we have a set S containing n elements. Now suppose we want to take subsets of size k from this set, where n >= k. There are a total of nCk such subsets possible. Now suppose we create a set S’ by removing one element, e, from S, so that S’ contains n-1 elements. For this new set, S’, we’re interested in subsets of size k-1. Trivially, there are (n-1)C(k-1) such subsets possible. But further, we can say that since S contains e and S’ does not, any subset of size k in S that contains e will be a unique subset of S’, of size k-1, if e is removed. Since the fraction of size-k subsets of S that contain e should be k/n, we arrive at the following equation: (k/n)*nCk = n-1Ck-1 k*nCk = n*n-1Ck-1 k*(nCk) (k*n!) / (k!(n-k)!) k*n! / (k*(k-1)!(n-k)!) = = = n*(n-1)C(k-1) n(n-1)! / ((k-1)!(n-1-(k-1))!) n! / ((k-1)!(n - k - 1 + 1)!) n! / ( (k-1)! * (n-1)! ) = n! / ( (k-1)! * (n-1)! ) Q.E.D. (Note, other solutions are also possible) (b) Math derivation (5 points) Q.E.D.