Task 2: Write a function bico(int n, int i) that returns the ith coefficient of binomial...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Task 2: Write a function bico(int n, int i) that returns the ith coefficient of binomial (x + y)". For example, bico(4,2) should return 6 because (x + y) = x + 4xy + 6xy + 4zy +y. CSCP 2430-02 Lab 11 Winter Quarter 2024 | Seattle University The second coefficient of (x + y) is 6. Notice that coefficient index starts from 0. Your program needs to receive two integers from user input. The first one refers to the degree of this binomial and the second one refers to the coefficient we want to obtain. For this lab, you must use Pascal's triangle to find the desired binomial coefficient. You must calculate the coefficients from previous Pascal triangle values. You are not allowed to use any formulas, combinatorial or other, to calculate the coefficients. Page 4 Your program must use dynamic memory allocation to store the Pascal Triangle up to the degree requested by the user. Your program should have an interface like the one below to receive input from users. After input is received, your program must print the Pascal Triangle up to the degree specified like below, AND print out the requested binomial coefficient value. [mjilani@csi labl]s g++ -Wall -Werror -pedantic -o lab labl.cpp [mjilani@csi labijs ./labl Input Please input the degree of the binomial: 4 Please input the index of the coefficient: 2 1 11 12 1 1 3 3 1 14641 The result is: 6 Task 2: Write a function bico(int n, int i) that returns the ith coefficient of binomial (x + y)". For example, bico(4,2) should return 6 because (x + y) = x + 4xy + 6xy + 4zy +y. CSCP 2430-02 Lab 11 Winter Quarter 2024 | Seattle University The second coefficient of (x + y) is 6. Notice that coefficient index starts from 0. Your program needs to receive two integers from user input. The first one refers to the degree of this binomial and the second one refers to the coefficient we want to obtain. For this lab, you must use Pascal's triangle to find the desired binomial coefficient. You must calculate the coefficients from previous Pascal triangle values. You are not allowed to use any formulas, combinatorial or other, to calculate the coefficients. Page 4 Your program must use dynamic memory allocation to store the Pascal Triangle up to the degree requested by the user. Your program should have an interface like the one below to receive input from users. After input is received, your program must print the Pascal Triangle up to the degree specified like below, AND print out the requested binomial coefficient value. [mjilani@csi labl]s g++ -Wall -Werror -pedantic -o lab labl.cpp [mjilani@csi labijs ./labl Input Please input the degree of the binomial: 4 Please input the index of the coefficient: 2 1 11 12 1 1 3 3 1 14641 The result is: 6
Expert Answer:
Related Book For
Data Analysis and Decision Making
ISBN: 978-0538476126
4th edition
Authors: Christian Albright, Wayne Winston, Christopher Zappe
Posted Date:
Students also viewed these algorithms questions
-
Hercules Hair Restorer Inc. (HHRI) makes many varieties of hair restoration products which are sold under well-known marketing labels. A single batch contains 10,000 8-oz. bottles and takes two days...
-
cck3 java help them all If a processor exhibited one branch delay slot how would you reorder (and possibly modify) the instructions in the following loop to gain a performance advantage? loop ldr...
-
What is a branch delay slot and why does it arise? [7 marks] How can branch delays be avoided? If a processor exhibited one branch delay slot how would you reorder (and possibly modify) the...
-
The manager of a $20 million portfolio of domestic stocks with a beta of 1.10 would like to begin diversifying internationally. He would like to sell $5 million of domestic stock and purchase $5...
-
Outline the major sources of leader power and explain how leaders can use power to encourage subordinate commitment.
-
According to data obtained by the U.S. Department of Agriculture, the relationship between a cow's total output of milk and the amount of grain it is fed is as follows: (This relationship assumes...
-
On March 1, 20XA, Chuck Larson purchases mineral rights (MR) for $30,000. On June 1, 20XA, he leases the mineral rights to Grey Wolf Oil Company, retaining a 1/5 royalty interest (RI). Grey Wolf Oil...
-
1. Why do you think P&G isolates the teams at Clay Street? Why is so much time spent up front on activities that are not directly related to the task? What are the advantages and disadvantages to...
-
K Part 1 of 3 O Points: 0 of 1 Use the value of the linear correlation coefficient to calculate the coefficient of determination. What does this tell you about the explained variation of the data...
-
Refer to the kinesiology data in Example 12.6 and the models fit to this data set in Exercises 12.23 and 12.24. a. Predict the maximal oxygen uptake for a person having a weight of 150 kg, an age of...
-
Oleumplc sells a soap called Fragro , which it buys in boxes of 1,000 bars with ordering costs of Tzs. 5,000 per order . Retail sales are 200,000 bars per year and holding costs are TZS. 195,312.50...
-
1. Source Amplitude (dB) 100 90 If a 1600 Hz tone with an intensity of 115dB SPL were passed through the resonator/filter to the right, the sound that came out would have an intensity of about dB 40-...
-
Sketch the block diagram of the air conditioner systems,identifying the input, output, the controller and theplant. ?
-
expert question lists here the benefits of all the experts
-
What is the package to model chemical equations in Python 3.0?
-
Idris Inc. manufactures entry and dining room lighting fixtures. Five activities are used in manufacturing the fixtures. These activities and their associated budgeted activity costs and activity...
-
please help A manager checked production records and found that a worker produced 294 units while working 60 hours. In the previous week, the same worker produced 200 units while working 50 hours. a....
-
A fast-food restaurant averages 150 customers per hour. The average processing time per customer is 90 seconds. a. Determine how many cash registers the restaurant should have if it wishes to...
-
A power company located in southern Alabama wants to predict the peak power load (i.e., Y, the maximum amount of power that must be generated each day to meet demand) as a function of the daily high...
-
The Tinkan Company produces one-pound cans for the Canadian salmon industry. Each year the salmon spawn during a 24-hour period and must be canned immediately. Tinkan has the following agreement with...
-
The file P08_49.xlsx contains data on 400 orders placed to the ElecMart Company over a period of several months. For each order, the file lists the time of day, the type of credit card used, the...
-
Jud's Manufacturing Company produces one product, Kebo. Because of wide fluctuations in demand for Kebo, the Assembly Department experiences significant variations in monthly production levels. The...
-
Lorch Company uses budgets in controlling costs. The May 2002 budget report for the company's Packaging Department is as follows. The budget amounts in the report were on the master budget For the...
-
Lakem elder Dutch manufactures expensive watch eases sold as souvenirs. Three ol its sales departments are: Retail Sales, Wholesale Sales, and Outlet Sales. The Retail Sales Department is a profit...
Study smarter with the SolutionInn App