Hi, I'm new here and need some help on beginning my program. I've read the thread on homework help and am not here asking for someone to do my program.

I have an assignment which I basically have to take in polynomials from the user and add/multiply them. I decided to use a linked list with this type declaration:

struct ATerm
{
    int Coefficient;
    int Exponent;
    ATerm *Next;
}
typedef ATerm *Polynomial

my question is how to store each polynomial the user input's. I'm not allowed to use the string functions which would make this problem trivial. Any ideas?

Edited 3 Years Ago by Reverend Jim: Fixed formatting

I've read the thread on homework help and am not here asking for someone to do my program.
I guess you didn't read about posting your code in the code tags:http://www.daniweb.com/forums/misc-explaincode.html

I decided to use a linked list with this type declaration
This is a Node of the linked list, not the linked list itself.
(I dont recomend the typedef you chose. monomial would have been a better option)
So you have a made a monomial Node. Good.
Now start by designing a Class which would actually make all those things to work.
Since it is a linked list, it wouldnt be as easy.
So, start writing the Class, write ways to input and output a polynomial etc.

I wouldnt bother with the exponent.
I would only use the coefficient and let the position in an "Array" be the exponent.

Exponents are by definition integers >0 ,
so it should be ideally suited for a simple array.

the polynomial
[TEX]a Z^4 -b Z^3+cZ+7[/TEX]
the last term has an invisble z^0
so it should be represented by

{7,c,0,-b,a}

sum would just be the placewise addition,
prod is somewhat more involved, but you should go backward in one of you list while multipling coefs.
It's a kind of convolution

good luck

Nice class,
I like you added a diff and eval function.

Maybe you should update it,
with inline operators +-*<<

Thanks for the input everyone!!!!
I'm getting started tonight!!

First off: The polynominal class, it is a start but you have a number of things to adjust.

First off polynominals have three common types of coefficient: complex , floating point (double etc) or polynomial. Note the last one: if you want to express [TEX]3y^2+xy+x^2+1 =0[/TEX] then you will want that type.

Then how you design your class is dependent on what you want it to do. The important things are: do you want to find roots.? Second do you need to solve simultanious equations (multi-variable). What sort of integrals do you want?

Second consider this polynomial equation:
[tex]3x^{-1}+5x^{-2}=0[/tex]
Perfectly valid equation, easy to integrate in the complex plane, easy to find roots.

Now that suggests a number of fundermental changes to the polynominal class.

(a) First use either a low/high exponent values or use the original exponent form. [e.g. equation above is -2,0]
(b) Use a vector or variable length polynomial power system.
(c) Implement multiplication first, it exposes most of the short-coming of the other designs, without being too difficult.
(d) Then do division.

Actually in a general context the coefficents can be whatever you want them to be.
Not necessary a field, but most likely a ring.

So it should actually be templated.

But I doubt that the original poster is looking at this level of sophistication.

This article has been dead for over six months. Start a new discussion instead.