Review questions for Final Exam1.A Pascal’s triangle with levels 0 to 4 is shown below. Level 0 has a single value, and each value on subsequentlevels is the sum of the two entries diagonally above in the previous level of the triangle. For example, the value6 in level 4 is the sum of the values 3 and 3 in level 3.111121133114641...level 0level 1level 2level 3level 4Complete functionpascalVectorbelow to return therow vectorcorresponding to a speci±ed level of Pascal’striangle. For example, if levellevis 4, then the returned vector must be [1,4,6,4,1]. Assume thatlevis anon-negative integer. The onlyMatlabbuilt-in functions allowed arezeros,ones, andlength.Do not use the formula for binomial coeﬃcients to solve this problem. Use a loop (or loops): the vector for eachlevel is based on the vector from the previous level.function p = pascalVector(lev)% p is the vector corresponding to level lev of Pascal’s triangle2.Cis a cell array with three components: a real number, a vector of numbers, and a matrix of numbers.
This is the end of the preview.
access the rest of the document.