Question
Pascal's Triangle is a famous way to list out the coefficients of a binomial expansion. (You should look this up as background to this assignment.
Pascal's Triangle is a famous way to list out the coefficients of a binomial expansion. (You should look this up as background to this assignment. Use recursion to print out the number of lines of this famous triangle that the user requests. Here are the first few lines of the triangle.
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
To make your output a little easier, you may output the triangle as
1
1 1
1 2 1
1 3 3 1
1 4 6 4 1
Rewrite your program for finding Pascal's Triangle above to use iteration (loops) instead of recursion. Include in both algorithms code to keep track of the total time used to run thealgorithms in milliseconds. Run these algorithms for n = 10, n = 20, and n = 30. Print out both the original output and the time to run for both algorithms.
Please make sure you comment your code thoroughly.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started