1. (Pascals Triangle Functionality) There are many applications of Pascals triangle. We discuss some of them and...
Question:
1. (Pascal’s Triangle Functionality)
There are many applications of Pascal’s triangle. We discuss some of them and the objective is to implement them in C++. Answer the following questions:
a) Construct the Sierpinski triangle that we create by filling the Pascal’s triangle black if the value is odd and white if the value is even. This tactic entails reducing each element modulo two. The output is a regular pattern of inverted triangles with sizes differing by powers of two.
b) Construct the following analogue to Pascal’s triangle. In this case we expand (x + 2)n instead of (x + 1)n where n is the row number. We set row 0 to {1} and row 1 to {2}.
The triangles are constructed according to the recursive formula:
(
n k )
= 2 (
n − 1 k − 1 )
+
(
n − 1 k )
, 1≤ k ≤ n.
Verify that the sum of elements of row n is 3n−1.
c) It is possible to compute the binomial distribution from Pascal’s triangle. To this end, let p be the probability of an event occurring and let us assume that p = 1/2. Divide the nth row by 2n and verify that the triangle becomes the binomial distribution.
Step by Step Answer: