Question: please asap You will solve the same exact problem as in Question 1, but, this time you will write a recursive Python function called generate_r(

please asapplease asap You will solve the same exact problem as in Question1, but, this time you will write a recursive Python function called

You will solve the same exact problem as in Question 1, but, this time you will write a recursive Python function called generate_r( n ) that generates a series or rows of numbers stored as sublists according to the above-mentioned rules. To help you, a possible algorithm for the task is provided to you below. Intentionally though, not every detail is given in this algorithm, and the details you need to fill in are all about how you must go about implementing each of the steps mentioned in this algorithm. Algorithm Generate_R( n ): IF n is 1 THEN: RETURN [[1]] ELSE: W = generate rows for the previous (n - 1) rows pp = grab the last row from vv rr = generate values for the current row using values in pp gg = build/join the entire set of rows from rr and w RETURN 88 The implemention below provides a few lines of the implementation of the above algorithm. On the other hand, you have complete freedom as to how you may wish to implement a solution, as long as that solution is recursive! The algorithm above and the code snippet below are only suggestions in the right direction. Remember that multiple solutions that satisfy the specifications are possible is no single solution. When you run the following cell, a file namd generate_r.py should be created, since a file magic directive is used at the top of the cell. You should not modify this line. Again, a function that you write may work. However, if it fails to follow the strict specifications provided to you, unfortunately, you will not get any grade for this question. So, if you do not remember additional specifications about what you are not allowed to do, please refer to Question 1 : TEST #2.1 (10 points) from generate_r import generate_r student_answer = generate_r( 1 ) correct answer [[1]] assert student_answer == correct answer TEST #2.2 (10 points) from generate_r import generate_r student_answer = generate_r( 2 ) correct answer [[1], [1, 1]] assert student_answer == correct answer TEST #2.3 (40 points) from generate_r import generate_r student_answer = generate_r( 6 ) correct answer = [[1], [1, 1], [1, 2, 1], [1, 3, 3, 1], [1, 4, 6, 4, 1], [1, 5, 10, 10, 5, 1]] assert student answer == correct_

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!