A polynomial may be represented as a linked list where each node contains the coefficient and...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a of the polynomial. The polynomial 4 X²-3 X²-5 would be represented as a linked list given below. Equation! 4 3 KEYWORDS: Classes Pointers Submit Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. -3 Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted). 2 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions. All methods used in the program MUST be written in C++ and included in the program. A) Equation1: Equation2: Result: s B) Equation1: Equation2: Result: 0 a. Documented program b. Input file. < Must contain the sample equations given below> e. Output file. d. All items stapled. C) Equation1: Equation2: Result: Test run for the following inputs (Do not change the order of exponent in the input file) 18X-7X³ +6X² +6 8X-7X+6X+9X²-8X+9 26X³7X-X³+15X²-8X+15 8X³-7X5+6X² +6 8X³-7X² +6X +9X³-8 X³ +6X+17X³-X² -2 8X³-6+5X³ +6X² +8X-7X+6X 9X³-6X²+5X+18X³-9 8X-7X7+14X+5X+26X¹6X-15 struct nodetype ( }; int coeff; int exp; nodetype *next; class equation { private: public: nodetype *begin, *last; int length; //Default constructor equation(); // Method to insert an item in the linked list in a sorted order void insertitem( nodetype temp); // Method to output all the items in the linked list void printlist(); // Method to add two equaition equation add(equation e2); A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a of the polynomial. The polynomial 4 X²-3 X²-5 would be represented as a linked list given below. Equation! 4 3 KEYWORDS: Classes Pointers Submit Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. -3 Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted). 2 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions. All methods used in the program MUST be written in C++ and included in the program. A) Equation1: Equation2: Result: s B) Equation1: Equation2: Result: 0 a. Documented program b. Input file. < Must contain the sample equations given below> e. Output file. d. All items stapled. C) Equation1: Equation2: Result: Test run for the following inputs (Do not change the order of exponent in the input file) 18X-7X³ +6X² +6 8X-7X+6X+9X²-8X+9 26X³7X-X³+15X²-8X+15 8X³-7X5+6X² +6 8X³-7X² +6X +9X³-8 X³ +6X+17X³-X² -2 8X³-6+5X³ +6X² +8X-7X+6X 9X³-6X²+5X+18X³-9 8X-7X7+14X+5X+26X¹6X-15 struct nodetype ( }; int coeff; int exp; nodetype *next; class equation { private: public: nodetype *begin, *last; int length; //Default constructor equation(); // Method to insert an item in the linked list in a sorted order void insertitem( nodetype temp); // Method to output all the items in the linked list void printlist(); // Method to add two equaition equation add(equation e2); A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a of the polynomial. The polynomial 4 X²-3 X²-5 would be represented as a linked list given below. Equation! 4 3 KEYWORDS: Classes Pointers Submit Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. -3 Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted). 2 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions. All methods used in the program MUST be written in C++ and included in the program. A) Equation1: Equation2: Result: s B) Equation1: Equation2: Result: 0 a. Documented program b. Input file. < Must contain the sample equations given below> e. Output file. d. All items stapled. C) Equation1: Equation2: Result: Test run for the following inputs (Do not change the order of exponent in the input file) 18X-7X³ +6X² +6 8X-7X+6X+9X²-8X+9 26X³7X-X³+15X²-8X+15 8X³-7X5+6X² +6 8X³-7X² +6X +9X³-8 X³ +6X+17X³-X² -2 8X³-6+5X³ +6X² +8X-7X+6X 9X³-6X²+5X+18X³-9 8X-7X7+14X+5X+26X¹6X-15 struct nodetype ( }; int coeff; int exp; nodetype *next; class equation { private: public: nodetype *begin, *last; int length; //Default constructor equation(); // Method to insert an item in the linked list in a sorted order void insertitem( nodetype temp); // Method to output all the items in the linked list void printlist(); // Method to add two equaition equation add(equation e2); A polynomial may be represented as a linked list where each node contains the coefficient and exponent of a of the polynomial. The polynomial 4 X²-3 X²-5 would be represented as a linked list given below. Equation! 4 3 KEYWORDS: Classes Pointers Submit Write a COMPLETE program that reads two polynomials in any order of exponent from an input file, stores them as sorted (in the descending order of the exponents) linked lists, adds them together, and prints the result as a polynomial to an output file. The result should be a third linked list. -3 Hint: Travers both polynomials. If a particular exponent value is present in either of the two polynomials being summed, then it should be present in the answer. If it is present in both polynomials, then its coefficient is the sum of the corresponding coefficient in both polynomials. (If this sum is zero, the term should be deleted). 2 NOTE: Must write a very general program using Object oriented concept. Do not use any library functions. All methods used in the program MUST be written in C++ and included in the program. A) Equation1: Equation2: Result: s B) Equation1: Equation2: Result: 0 a. Documented program b. Input file. < Must contain the sample equations given below> e. Output file. d. All items stapled. C) Equation1: Equation2: Result: Test run for the following inputs (Do not change the order of exponent in the input file) 18X-7X³ +6X² +6 8X-7X+6X+9X²-8X+9 26X³7X-X³+15X²-8X+15 8X³-7X5+6X² +6 8X³-7X² +6X +9X³-8 X³ +6X+17X³-X² -2 8X³-6+5X³ +6X² +8X-7X+6X 9X³-6X²+5X+18X³-9 8X-7X7+14X+5X+26X¹6X-15 struct nodetype ( }; int coeff; int exp; nodetype *next; class equation { private: public: nodetype *begin, *last; int length; //Default constructor equation(); // Method to insert an item in the linked list in a sorted order void insertitem( nodetype temp); // Method to output all the items in the linked list void printlist(); // Method to add two equaition equation add(equation e2);
Expert Answer:
Answer rating: 100% (QA)
It looks like youre asking for help developing a C program to add two polynomials represented as linked lists The question specifies an equation class ... View the full answer
Related Book For
Java An Introduction To Problem Solving And Programming
ISBN: 9780134462035
8th Edition
Authors: Walter Savitch
Posted Date:
Students also viewed these programming questions
-
For the current year, Conres Corp., a CCPC, has aggregate investment income (AII) of $110,000 and taxable income of $400,000, of which $290,000 is eligible for the SBD. Federal Part I tax is $68,633....
-
you will be asked to put together a series of written communication that focuses on positive messaging for a variety of audiences. You will write a(n) E-mail encouraging employees to be more...
-
The second programming project involves writing a program that examines a file of polynomials and determines whether the polynomials in that file are in strictly ascending order using two different...
-
For numbers a and b, determine which of the following expressions equals the given expression. (a) a + b (b) a b (c) b a (d) a b a + (b)
-
List four design issues for which the concept of concurrency is relevant.
-
Find the angle between 0 and 2 equivalent to 13/4.
-
True or False: A bearing that shows signs of brinelling but no sign of surface deformation or corrosion can yield a full life.
-
Midland National Bank selected a sample of 40 student checking accounts. Below are their end-of-the-month balances. a. Tally the data into a frequency distribution using $100 as a class interval and...
-
When working in a group setting, what are some of the strategies you would implement to encourage group cohesiveness and reduce social loafing?
-
As customers shifted to shopping online, Best Buy's 1,100 giant stores, which enabled the company to obtain its position as the largest retailer of electronics, began to reduce its profitability and...
-
An end-of-period adjustment for sales returns and allowances that will occur in the following period a. is not required by GAAP. b. is consistent with the matching principle. c. affects the balance...
-
Amadeus Corporation had the following information for the year 2018: Accounts Receivable, beginning 3,000,000 Allowance for Doubtful Accounts, beginning 150,000 Sales (80% on credit) 12,000,000 Sales...
-
Create an improved Marketing Strategy that innovates how Innisfree sells Korean skincare in the US. Revitalizing Innisfree's US Market Penetration and Competitive Edge in Korean Skincare. Industry...
-
Mauro Products distributes a single product, a woven basket whose selling price is $24 per unit and whose variable expense is $20 per unit. The company's monthly fixed expense is $10,000. Required...
-
In 2019, Sammy Miller drove a rocket powered dragster from rest to 402m (1/4 mile) in a record 3.22s. What acceleration did he experience?
-
what ways do social movements serve as agents of change, and how do factors such as ideology, organizational structure, and collective action strategies influence their effectiveness in challenging...
-
The management of Bootleg Company wants to know the break-even point for its new line of hiking boots under each of the following independent assumptions. The selling price is $50 per pair of boots...
-
The executor of Gina Purcells estate has recorded the following information: Assets discovered at death (at fair value): Cash . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . ....
-
The following flowchart contains a series of questions to determine what kind of haircut to get. Write a program that asks the questions to the user and outputs the recommended haircut based on the...
-
Consider a class that could be used to play a game of hangman. The class has the following attributes: The secret word. The disguised word, in which each unknown letter in the secret word is replaced...
-
Complete and fully test the class Time that Exercise 2 describes. Add two more constructors that are analogous to the setTime methods described in Parts c and d of Exercise 2. Also include the...
-
A positively charged particle creates the electric field shown in Figure 30. 20. When the kinks in the electric field lines reach the rod, what is the direction of the current induced in the rod?...
-
Suppose the current shown in Figure 30. 19 discharges the capacitor. What are the directions of \(\vec{E}\), \(\Delta \vec{E}\), and \(\vec{B}\) between the plates of the discharging capacitor? Data...
-
For the oscillating dipole of Figure 30. 14, sketch the electric field pattern at \(t=\frac{5}{4} T\). Data from Figure 30.14 0=1 t = T t=T 1=T O O D
Study smarter with the SolutionInn App