Question: Question: Code so far(Please improve on this code thanks): The last program will use recursion to generate the levels of Pascal's triangle You should read

Question:

Question: Code so far(Please improve on this code thanks): The last programwill use recursion to generate the levels of Pascal's triangle You should

Code so far(Please improve on this code thanks):

read the Wikipedia page for information about Pascal's triangle, paying special attention

The last program will use recursion to generate the levels of Pascal's triangle You should read the Wikipedia page for information about Pascal's triangle, paying special attention to how the triangle is constructed. The program must contain a main() and a recursive function called pascal (), implemented as described in the function header comment given below. (You should include this function header comment in your own code.) # pascal() uses recursion to create each level of Pascal's triangle, reachlng the requested height # Input: currLevel; an int, the current level being created levelsToMake; an int, the number of levels requested levelList; a 2D list of ints, containing the levels as they are created # Output: None (1evelList is changed in place, and the updated levelList will be the same in main )) Your code must perform basic input validation to ensure that numbers are greater than or equal to 1, and tell the user what it will accept as valid input. Think carefully about what your base cases should be! Also, note that the code should follow the conventional numbering of a Pascal's triangle: the first row (the single 1 at the top) is row zero, meaning that a request for a triangle of height 5 will result in six rows being generated in total It is also highly recommended that you create a Pascal's triangle by hand (to a height of at least 8), paying attention to the steps taken as you go, prior to beginning your code (You do not need to worry about printing out a "centered" triangle - the numbers being left-aligned (as seen in the sample output) is acceptable.) The last program will use recursion to generate the levels of Pascal's triangle You should read the Wikipedia page for information about Pascal's triangle, paying special attention to how the triangle is constructed. The program must contain a main() and a recursive function called pascal (), implemented as described in the function header comment given below. (You should include this function header comment in your own code.) # pascal() uses recursion to create each level of Pascal's triangle, reachlng the requested height # Input: currLevel; an int, the current level being created levelsToMake; an int, the number of levels requested levelList; a 2D list of ints, containing the levels as they are created # Output: None (1evelList is changed in place, and the updated levelList will be the same in main )) Your code must perform basic input validation to ensure that numbers are greater than or equal to 1, and tell the user what it will accept as valid input. Think carefully about what your base cases should be! Also, note that the code should follow the conventional numbering of a Pascal's triangle: the first row (the single 1 at the top) is row zero, meaning that a request for a triangle of height 5 will result in six rows being generated in total It is also highly recommended that you create a Pascal's triangle by hand (to a height of at least 8), paying attention to the steps taken as you go, prior to beginning your code (You do not need to worry about printing out a "centered" triangle - the numbers being left-aligned (as seen in the sample output) is acceptable.)

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!