Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

# Thread: Urgent Polynomial Assignment !!!!!!!!!

1. ## 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 !!!

2. ## Re: Urgent Polynomial Assignment !!!!!!!!!

Recommended reading: Starting Writing a Program

3. ## Re: Urgent Polynomial Assignment !!!!!!!!!

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

4. ## Re: Urgent Polynomial Assignment !!!!!!!!!

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.

5. ## The Following User Says Thank You to jps For This Useful Post:

KevinWorkman (October 9th, 2012)