Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A polynomial may be represented using a linked list as follows: for every term in the polynomial there is one entry in the linked list

A polynomial may be represented using a linked list as follows: for every term in the polynomial there is one entry in the linked list consisting of the term's coefficient and degree. The entries are ordered according to ASCENDING values of degree, i.e. lowest degree term first, then next lowest degree term and so on, all the way up to the highest degree term. IMPORTANT: Zero-coefficient terms are NOT stored.

or example, the following polynomial (the symbol '^' is used to mean 'raised to the power'):

 4x^5 - 2x^3 + 2x +3 

can be represented as the linked list of terms:

 (3,0) -> (2,1) -> (-2,3) -> (4,5) 

where each term is a (coefficient,degree) pair.

  • O NOT remove the package line at the top of the file.
  • DO NOT remove any of the import statements.
  • DO NOT add any import statements.
  • DO NOT change the headers of ANY of the given methods
  • DO NOT change/remove any of the given class fields
  • DO NOT add any new class fields - this includes variables and classes.
  • YOU MAY add new helper methods, but you must declare them private.

Create a method to evaluate the polynomial following this example test run

8.0x^4 + 4.0x^3 + -3.0x + 9.0
1. ADD polynomial 2. MULTIPLY polynomial 3. EVALUATE polynomial 4. QUIT Enter choice # => 3 Enter the evaluation point x => 2 Value at 2.0: 119.0

Here's the starting part of the code, do not change anything or add anything.

package poly;

import java.io.IOException;

import java.util.Scanner;

public static float evaluate(Node poly, float x) {

/** COMPLETE THIS METHOD **/

// FOLLOWING LINE IS A PLACEHOLDER TO MAKE THIS METHOD COMPILE

// CHANGE IT AS NEEDED FOR YOUR IMPLEMENTATION

return 0;

}

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

Step: 3

blur-text-image

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

Database Concepts International Edition

Authors: David M. Kroenke

6th Edition International Edition

0133098222, 978-0133098228

More Books

Students also viewed these Databases questions

Question

4. Identify cultural variations in communication style.

Answered: 1 week ago

Question

9. Understand the phenomenon of code switching and interlanguage.

Answered: 1 week ago

Question

8. Explain the difference between translation and interpretation.

Answered: 1 week ago