finalReview - Review questions for Final Exam 1 A Pascal's...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
Review questions for Final Exam 1. A Pascal’s triangle with levels 0 to 4 is shown below. Level 0 has a single value, and each value on subsequent levels is the sum of the two entries diagonally above in the previous level of the triangle. For example, the value 6 in level 4 is the sum of the values 3 and 3 in level 3. 1 11 121 1331 14641 . . . level 0 level 1 level 2 level 3 level 4 Complete function pascalVector below to return the row vector corresponding to a speci±ed level of Pascal’s triangle. For example, if level lev is 4, then the returned vector must be [1 , 4 , 6 , 4 , 1]. Assume that lev is a non-negative integer. The only Matlab built-in functions allowed are zeros , ones , and length . Do not use the formula for binomial coefficients to solve this problem. Use a loop (or loops): the vector for each level is based on the vector from the previous level. function p = pascalVector(lev) % p is the vector corresponding to level lev of Pascal’s triangle 2. C is a cell array with three components: a real number, a vector of numbers, and a matrix of numbers.
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

Ask a homework question - tutors are online