Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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:

image text in transcribedimage text in transcribed

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Oracle8I Building Efficient Databases

Authors: Jonathan Lewis

1st Edition

0201715848, 978-0201715842

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago