Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

CPS 2340 Lab 3 2 preerams) LLL A polynomial can be represented as a linked list, where each node called a polyNode contains the coefficient

image text in transcribed
image text in transcribed
CPS 2340 Lab 3 2 preerams) LLL A polynomial can be represented as a linked list, where each node called a polyNode contains the coefficient and the exponent of a term of the polynomial. 1. For example, the polynomial 4x3x-5 would be represented as the linked list: 3x2 Write a Polynomial class that has methods for creating a polynomial, reading and writing a polynomial, and adding a pair of polymomials. In order to add 2 polynomials, traverse both lists. If a particular exponent value is present in either one, it should also be present in the resulting polymomial unless its coefficient is zero. 2. Each student at Kean University takes a different number of courses, so the . registrar has decided to use linear linked lists to store each student's class schedule and an array to represent the entire student body. A portion of this dgta structure is shown below I 1234 23511 These data show that the first student (TD: 1111) is taking section 1 of CSC162 for 3 credits and section 2 of HIS101 for 4 credits; the second student is not enrolled: the third student is enrolled in CSC236 section 4 for 3 credits. Write a class for this data structure. Provide methods for creating the original array inserting a student's initial class schedule, adding a course, and dropping a course. Include a menu-driven program that uses the class Lab 3 Directions (linked lists) Program #1 1. Show PolynomialADT interface 2. Create the PolyNodeClass with the following methods: default constructor, overloaded constructor, copy constructor, setCoefficient, setExponent, setNext, getCoefficient, getExponent, getNext 3. Create the PolynomialDataStrucClass with the following methods: default constructor, overloaded constructor, copy constructor, isEmpty setFirstNode, getFirstNode, addPolyNodeFirst (PolyNode is created and set to beginning of polynomial), addPolyNodeLast, addPolyNode (PolyNode is set to the end of polynomial), addPolynomials, toString 4. Create the PolynomialDemoClass: instantiate and initialize PolynomialDataStrucClass objects pl, p2, p3, p4 Add terms to the polynomials (pass 2 arguments to the method: coefficient - and exponent- for example: pl.addPolyNodeLast(4, 3):) Print out pl, p2 and sum of the polynomials AND p3, p4, and sum of the polynomials Use: pl: 4x 3 +3x*2 -5 p2 3x 5+4x 4+x"3-4x 2+4x 1 2 AND

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

Students also viewed these Databases questions