Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Pascal's triangle, illustrated on page 419 in the text, has rows that begin and end with 1. Within that, the numbers in each row are

Pascal's triangle, illustrated on page 419 in the text, has rows that begin and end with "1". Within that, the numbers in each row are the pairwise sums of the numbers in the row above. Consider the following recursive algorithm intended to return row n of Pascal's triangle, if the row at the top is designated to be the 0 row.

Triangle(n)

If n=0

return [1]

b=Triangle(n-1)

c is a vector of length n+1 with starting index equal to 1.

c[1]=1

c[n+1]=1

for (j in 1 to n-1){

c[j+1]=b[j]+b[j+1]

}

return c

2.a. What is the base case? Does the algorithm return correctly in the base case?

2.b. Does the algorithm terminate on non-negative integer input? If so, why? If not, give an example of input on which it fails to terminate.

2.c. If the recursive call returns correctly, does the algorithm return the correct output?

2.d. Does the algorithm perform correctly? If so, why? If not, why not?

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

Professional SQL Server 2000 Database Design

Authors: Louis Davidson

1st Edition

1861004761, 978-1861004765

More Books

Students also viewed these Databases questions