Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1. Trinomial coefficients (brute force). Write a program Trinomia 1 Brute. java that takes two integer command-line arguments n and k and computes the corresponding

image text in transcribed
1. Trinomial coefficients (brute force). Write a program Trinomia 1 Brute. java that takes two integer command-line arguments n and k and computes the corresponding trinomial coefficient. The trinomial coefficient T(n,k) is the coefficient of xn+k in the expansion of (1+x+x2)n. For example, (1+x+x2)2=1+3x+6x2+7x2+6x4+3x5+x6 Thus, T(3,3)=1,T(3,2)=3,T(3,1)=6, and T(3,0)=7. Implement a recursive function trinomial () to compute T(n,k) by using the following recurrence relation: T(n,k)=10T(n1,k1)+T(n1,k)+T(n1,k+1)Ifn0notk0ifknoblerwie To do so, organize your program according to the following public API: public class TrinomialBrute \{ / Returns the trinomial coefficient T(n,k). public static long trinomial(int n,, int k ) public static void main (String[] args) \} As you will see, this approach is hopeless slow for moderately large values of n and k. Note: you may assume that n is a non-negative integer. Trinomial coefficients arise in combinatorics. For example, T(n,k) is the number of permutations of n symbols, each of which is 1, 0, or +1, which sum to exactly k and T(n,kn) is the number of diffenent ways of randomly drawing k cards from two identical decks of n playing cards

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_2

Step: 3

blur-text-image_3

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

Beginning PostgreSQL On The Cloud Simplifying Database As A Service On Cloud Platforms

Authors: Baji Shaik ,Avinash Vallarapu

1st Edition

1484234464, 978-1484234464

More Books

Students also viewed these Databases questions