Question
Question: Pascal's triangle, illustrated on page 419 in the text, has rows that begin and end with 1. Within that, the numbers in each row
Question:
Pascal's triangle, illustrated on page 419 in the text, has rows that begin and end with "1". Within that, the numbers in each row are the pairwise sums of the numbers in the row above. Consider the following recursive algorithm intended to return row n of Pascal's triangle, if the row at the top is designated to be the 0 row.
Triangle(n)
If n=0
return [1]
b=Triangle(n-1)
c is a vector of length n+1 with starting index equal to 1.
c[1]=1
c[n+1]=1
for (j in 1 to n-1){
c[j+1]=b[j]+b[j+1]
}
return c
2.a. What is the base case? Does the algorithm return correctly in the base case?
2.b. Does the algorithm terminate on non-negative integer input? If so, why? If not, give an example of input on which it fails to terminate.
2.c. If the recursive call returns correctly, does the algorithm return the correct output?
2.d. Does the algorithm perform correctly? If so, why? If not, why not?
Pascal's Identity and Triangle The binomial coefficients satisfy many different identities. We introduce one of the most im- portant of these now. THEOREM 2 PASCAL S IDENTITY Let n and k be positive integers with n 2 k. Then n 1 Proof: We will use a combinatorial proof. Suppose that T is a set containing n 1 elements. Let a be an element in T, and let S T (a). Note that there are n--1 subsets of T containing k 1) elements. However, a subset of T with k elements either contains a together with k 1 elements of S, or contains k elements of S and does not contain a. Because there are (k" subsets of k 1 elements of S, there are (k" subsets of k elements of T that contain a. And there are (R) subsets of k elements of T that do not contain a, because there are (A) subsets of k elements of S. Consequently, n 1 Remark: It is also possible to prove this identity by algebraic manipulation from the formula for (m) (see Exercise 19). Pascal's Identity and Triangle The binomial coefficients satisfy many different identities. We introduce one of the most im- portant of these now. THEOREM 2 PASCAL S IDENTITY Let n and k be positive integers with n 2 k. Then n 1 Proof: We will use a combinatorial proof. Suppose that T is a set containing n 1 elements. Let a be an element in T, and let S T (a). Note that there are n--1 subsets of T containing k 1) elements. However, a subset of T with k elements either contains a together with k 1 elements of S, or contains k elements of S and does not contain a. Because there are (k" subsets of k 1 elements of S, there are (k" subsets of k elements of T that contain a. And there are (R) subsets of k elements of T that do not contain a, because there are (A) subsets of k elements of S. Consequently, n 1 Remark: It is also possible to prove this identity by algebraic manipulation from the formula for (m) (see Exercise 19)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started