Question: I have to write two Pascal's Triangle functions in python: Pascal's Triangle function 1. To construct Pascal's Triangle, each number at a given ( row

I have to write two Pascal's Triangle functions in python:

Pascal's Triangle function 1.

To construct Pascal's Triangle, each number at a given (row, column) location can be computed by summing the two numbers above it. The numbers on the edges are always 1.

Write a function called pascal(row, col) that computes the number at the given (row, col) by using the formula above. It's a recursive function. The base case is when (row, col) corresponds to one of the edges. Otherwise, it sums the two values above.

Pascal's Triangle function 2 using Memoization.

Make a new function called mpascal(row, col) that uses memoization to speed up the computation.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!