Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

coding in Matlab Function Name: pascalsPodium Inputs: 1. ( double ) The number of rows to include in your output Outputs: 1. (double) An array

coding in Matlab

Function Name: pascalsPodium

Inputs:

1. ( double ) The number of rows to include in your output

Outputs:

1. (double) An array representing the podium

Banned Functions:

 nchoosek(), pascal() 

Background:

You have been hired by the International Olympic Committee to design the closing ceremonies. You and your team have all the flower bouquets picked out, ordered the medals, and purchased all the streamers and confetti, but still have one extremely important task: designing the podium. Reminiscing back to high school calculus, you remember learning about Pascals triangle and decide it would be the perfect starting point to constructing the Olympic podium. However, mapping out rows and rows of blocks to recreate Pascals triangle can be tedious, so you choose to use your amazing MATLAB skills to do it for you.

Function Description:

Given the number of rows of Pascal's triangle to include in your final output, build a double array containing the triangle, with zeros filling the spaces in between. For example, the first four rows of Pascal's triangle are usually written in the following fashion:

1

1 1

1 2 1

1 3 3 1

Since the rows of the triangle are offset from one another, our MATLAB representation of the triangle will include zeros to fill the gaps. So we can show the first four rows of the triangle as the following 4x7 double array:

0

0

0

1

0

0

0

0

0

1

0

1

0

0

0

1

0

2

0

1

0

1

0

3

0

3

0

1

Each row of Pascal's triangle is constructed by summing adjacent elements of the row above it. For example, to find the value of a certain position, go to the position directly above it (the previous row) and sum the values directly to the right and left of it.

Given this, you can create the array by starting with the first row (it will always be a single 1 in the center of the row), and iterating through the rest of the rows, using the elements of the previous row to create each subsequent row.

Notes:

Inputs to this function will be integers greater than 1.

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

What are postretirement benefits other than pensions?

Answered: 1 week ago

Question

State the uses of job description.

Answered: 1 week ago

Question

Explain in detail the different methods of performance appraisal .

Answered: 1 week ago