Problem

As early as the tenth century, mathematicians studied the following triangular pattern of...

As early as the tenth century, mathematicians studied the following triangular pattern of integers, now known as Pascal’s Triangle:

Despite the early advent of this pattern, it was named after the 17th-century mathematician Blaise Pascal.

Staggering the entries, as we have here, is traditional. Each row begins and ends with 1. Each interior entry is the sum of the two entries above it. For example, in the last row given here, 4 is the sum of 1 and 3, 6 is the sum of 3 and 3, and 4 is the sum of 3 and 1.

If we number both the rows and the entries in each row beginning with 0, the entry in position k of row n is often denoted as C(n, k). For example, the 6 in the last row is C(4, 2). Given n items, C(n, k) turns out to be the number of ways that you can select k of the n items. Thus, C(4, 2), which is 6, is the number of ways that you can select two of four given items. So if A, B, C, and D are the four items, here are the six possible choices:

A B, A C, A D, B C, B D, C D

Note that the order of the items in each pair is irrelevant. For instance, the choice A B is the same as the choice B A.

Design and implement the class PascalTriangle. Represent each row in a triangle as a list and the entire triangle as a list of these lists. Use the class ArrayList for these lists. Give your class constructors and at least the method getChoices(n, k), which returns the integer value of C(n, k).

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 12
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT