Urgent Polynomial Assignment !!!!!!!!!
Hey Guys
I need to create a mini program which adds and subtracts polynomials using only an ArrayList structure !!
I am really struggling to think of how to start to design this program
I know that an ArrayList is like array but dynamic and does not have to have a fixed number of elements.
I was thinking of using the index of the array list as the exponent and storing coefficients in the actual array list but don't really know how to start
I would really apperciate any suggestions !!!
Re: Urgent Polynomial Assignment !!!!!!!!!
Re: Urgent Polynomial Assignment !!!!!!!!!
Quote:
Originally Posted by
thesoulpatchofBruce
Hey Guys
I need to create a mini program which adds and subtracts polynomials....
Deciding on the data structure for the polynomials is a good way to start.
Given that you are supposed to use an ArrayList, the only thing to decide is what to put in the ArrayList.
So, suppose you are given a polynomial of degree n:
a0 + a1*x + a2*(x to the power 2) + a3 * (x to the power 3) + ... + an * (x to the power n)
There are n+1 coefficients that define a polynomial of degree n. (Note that if an is equal to zero, its degree is less than n, so that statements assumes that an is not zero).
One way to handle polynomials is what I think you mean: for an ArrayList, the coefficient of (x to the power k) will be stored in the array list index k for k = 0, 1, ..., n. (That is, a0 would be stored in the zero index position, then a1 would be stored in the index 1 position, etc.)
(Another way would be to put the coefficient of the highest power first.)
I like your way better, but there are reasons that some folks do it the otherway round.
Cheers!
Z
Re: Urgent Polynomial Assignment !!!!!!!!!
Quote:
Urgent Polynomial Assignment !!!!!!!!!
Speaking in terms of me getting out of the ocean and skipping across the beach, it does not matter how many '!' you put in the title, or how urgent your assignment is to you, I get out when I get out, and I check the forum when I feel like it. Just like the other people who volunteer their time here.
On the other hand, speaking in terms of common courtesy, it is not an acceptable practice to do things like all caps the title, or add multiple '!' on the end. Drawing this kind of attention to your post will actually cause many people to complain about your title rather than offering assistance with the question in your post, or ignore the post completely.