Objectives To create a linked-chain data structure To understand how to apply mathematical algorithms...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Objectives • To create a linked-chain data structure • To understand how to apply mathematical algorithms Instructions For this program, you will implement two classes, one representing a single term, and one representing a polynomial. The Polynomial class must support the following: . 2 constructors . . o A constructor that takes two parameters: exponent and coefficient A copy constructor A print method Recall that if we have, for example, the term 3x², then 3 is the coefficient, and 2 is the exponent Operations 0 o The method should print the polynomial This constructor will take, as its argument, a reference to the Polynomial which it is supposed to copy . clone method This method is inherited from Object You must override it to work correctly It copies and returns a new Polynomial object, which is a (deep) copy of the original that it is cloning . . o A Term node reference to point to the next node in the chain of linked nodes o Methods to get and set the exponent, coefficient, and next node The Polynomial class must keep track of the first node in the polynomial. Therefore one of its fields should be a Term reference Although the two-parameter constructor only allows a Polynomial to contain a single term to start off with, the add method allows for terms and larger polynomials to be combined, and the copy constructor and clone methods allow for creation and copying of larger polynomials When the add method is called, the polynomial that is passed in is added to whatever exists in the current polynomial For example: If polyA contains the polynomial 3x²+2x+5 and poly8 contains 3x+2, then the polyA will become: 3x² + 5x+7 Each of the terms, 3x², 5x, and 7 have their own Term object associated with them. They are in a linked chain. You can assume that all Polynomials will maintain and be passed in by standard form. For example, the polynomial inputs to add, or that will be copied, etc. - will always keep the form 3x² + 2x + 5, not something else like 2x+5+ 3x². The highest term always comes first, then second highest, etc. Some polynomials might have "missing" terms. Not all will be given with all the intermediate terms. For example, 5x² + 2x would be a perfectly acceptable polynomial, even though there is no x² term or constant o Note that a constant would be represented in a Term object by having an exponent of 0, because 2x⁰ = 2, since anything to the nower 0 is 1 we would have ?*1=2 Note that a constant would be represented in a Term object by having an exponent of 0, because 2x = 2, since anything to the power 0 is 1, we would have 2*1 = 2. • A visual of a polynomial chain would look like this: . To represent the polynomial 3x² + 2x + 3, we would have polyRef→[3x²] → [2x] → [3]→null For 4x³ - 2x you would have: polyRef →[4x³] → [-2x]→null Notice that the "minus" is represented by having the coefficient of the second term in the polynomial set to a -2. Major Hints / Design considerations: While coming up with a solution might seem daunting, especially when you must copy, add, or clone an entire arbitrary-length polynomial, keep some things in mind: o Like-terms are combined when add is called E.g., if you have the two polynomials polyA and polyB, and they each have respective x² terms, you add the coefficients If you are traversing a polynomial, you know you're finished when you reach null Objectives • To create a linked-chain data structure • To understand how to apply mathematical algorithms Instructions For this program, you will implement two classes, one representing a single term, and one representing a polynomial. The Polynomial class must support the following: . 2 constructors . . o A constructor that takes two parameters: exponent and coefficient A copy constructor A print method Recall that if we have, for example, the term 3x², then 3 is the coefficient, and 2 is the exponent Operations 0 o The method should print the polynomial This constructor will take, as its argument, a reference to the Polynomial which it is supposed to copy . clone method This method is inherited from Object You must override it to work correctly It copies and returns a new Polynomial object, which is a (deep) copy of the original that it is cloning . . o A Term node reference to point to the next node in the chain of linked nodes o Methods to get and set the exponent, coefficient, and next node The Polynomial class must keep track of the first node in the polynomial. Therefore one of its fields should be a Term reference Although the two-parameter constructor only allows a Polynomial to contain a single term to start off with, the add method allows for terms and larger polynomials to be combined, and the copy constructor and clone methods allow for creation and copying of larger polynomials When the add method is called, the polynomial that is passed in is added to whatever exists in the current polynomial For example: If polyA contains the polynomial 3x²+2x+5 and poly8 contains 3x+2, then the polyA will become: 3x² + 5x+7 Each of the terms, 3x², 5x, and 7 have their own Term object associated with them. They are in a linked chain. You can assume that all Polynomials will maintain and be passed in by standard form. For example, the polynomial inputs to add, or that will be copied, etc. - will always keep the form 3x² + 2x + 5, not something else like 2x+5+ 3x². The highest term always comes first, then second highest, etc. Some polynomials might have "missing" terms. Not all will be given with all the intermediate terms. For example, 5x² + 2x would be a perfectly acceptable polynomial, even though there is no x² term or constant o Note that a constant would be represented in a Term object by having an exponent of 0, because 2x⁰ = 2, since anything to the nower 0 is 1 we would have ?*1=2 Note that a constant would be represented in a Term object by having an exponent of 0, because 2x = 2, since anything to the power 0 is 1, we would have 2*1 = 2. • A visual of a polynomial chain would look like this: . To represent the polynomial 3x² + 2x + 3, we would have polyRef→[3x²] → [2x] → [3]→null For 4x³ - 2x you would have: polyRef →[4x³] → [-2x]→null Notice that the "minus" is represented by having the coefficient of the second term in the polynomial set to a -2. Major Hints / Design considerations: While coming up with a solution might seem daunting, especially when you must copy, add, or clone an entire arbitrary-length polynomial, keep some things in mind: o Like-terms are combined when add is called E.g., if you have the two polynomials polyA and polyB, and they each have respective x² terms, you add the coefficients If you are traversing a polynomial, you know you're finished when you reach null
Expert Answer:
Related Book For
Research Methods For Business Students
ISBN: 9781292208787
8th Edition
Authors: Mark Saunders, Philip Lewis, Adrian Thornhill
Posted Date:
Students also viewed these databases questions
-
You are considering the decision of whether or not to crash your project. After asking your operations manager to conduct an analysis, you have determined the "precrash" and "postcrash" activity...
-
What costs are irrelevant for the decision of whether to sell a joint product or process it further?
-
What issues affect the decision of whether to standardize or adapt international advertising?
-
Lang Enterprises was started when it acquired $4,000 cash from creditors and $6,000 from owners. The company immediately purchased land that cost $9,000. Required a. Record the events under an...
-
Graph y = 40x: + 160, x > 0.
-
Under the original concept of the corporation, the shareholders are the primary reason that a corporation exists. True/false
-
A contract is created to refurbish a luxury yacht: new color schemes, new furniture, new wall and floor coverings, new light fixtures, and window treatmentsthe whole works. Of course, it is not just...
-
The Mobile Oil company has recently acquired oil rights to a new potential source of natural oil in Alaska. The current market value of these rights is $90,000. However, if there is natural oil at...
-
- Suppose that Brine Freez servings sell for $4 each; capital is paid a daily rental rate of $20 ; and labor is paid a daily wage of $80 . - Calculate the value of marginal product of labor (L) and...
-
Assume that the Special Contract Division of Smith experienced the following transactions during the year ended December 31, 2020. i (Click the icon to view the transactions.) Requirements 1. Prepare...
-
A photo detector circuit is being used to generate a pulse each time a customer walks into a certain establishment. The pulses are fed to an eight-bit counter. The counter is used to count these...
-
George purchased three stocks (Stock X, Stock Y, and Stock Z) as investments on December 31, 20x1. He sold Stock X on December 31, 20x2, Stock Y on January 1, 20x3, and Stock Z on January 2, 20x3....
-
Luna is an active mutual fund manager. She uses a binomial model to estimate a price target for three stocks that she currently owns. Here are the price targets and market prices for each stock:...
-
https://youtu.be/sWZphFCcz7Q Watch the Week 3 Discussion Video. The information presented in the video will prepare you to answer your reply prompts. 2. Initial Post: Create a new thread and answer...
-
1. how you would describe what it is that you are studying at your university(not just this class) to someone that has never gone to university and is not familiar with your degree. ( My major is...
-
The following selected data were taken from the records of J. GEPIGA Merchandising Company for the year 2022 UNEARNED INCOME/REVENUE P 10,200.00 SALES RETURNS AND ALLOWANCES P 31,250.00 BEGINNING...
-
Muhammad paid $485 for the annual registration on his truck. The fee includes: $75 registration fee. $10 plate fee. $400, 1% of the assessed value of the vehicle. What amount can he deduct on the...
-
(a) What do data breach notification laws require? (b) Why has this caused companies to think more about security?
-
Briefly describe when you would use regression analysis and correlation analysis, using examples to illustrate your answer.
-
Visit an online database or your university library and obtain a copy of a research-based refereed journal article that you think will be of use to an assignment you are currently working on. Read...
-
Revisit Table 1.2 and look at the differences in management researcher and practitioner orientations for foci of interest, methodological imperatives, key outcomes and how each views the other. For...
-
You need to understand the approach described in question 3 in More Genetic TIPS before answering this question. A gene that is normally expressed in pancreatic cells was cloned and then subjected to...
-
Many researchers are interested in the transcription of protein-encoding genes in eukaryotes. Such researchers want to study mRNA. One method that is used to isolate mRNA is column chromatography....
-
The type of model building used by Pauling and by Watson and Crick involved the use of ball-and-stick units. Model building can now be done with computer software. Even though you may not be familiar...
Study smarter with the SolutionInn App