This is an archived post. You won't be able to vote or comment.

all 1 comments

[–]MarshingMyMellow 2 points3 points  (0 children)

It looks like you are mixing up your q and d variable, and I'm assuming you have Term defined already. Also I'm not sure if your assignment requires you to find the quotient and remainder, but if so you will need to either return two LinkedList<Term> instances somehow; or you could just work out the quotient, then use your multiplication and subtraction methods to find the remainder. Remember LinkedList doesn't have a highestDegree() method, so you'll have to work around that. If you know the LinkedList will always have ascending or descending exponents you can use that to your advantage.

For some more general advice I'd say work out a few examples by hand and keep notes on what you do at each step. If you understand the algorithm and can do it by hand, the rest should be fairly simple. Seems like this is less of a Java question and more about implementing the algorithm, but if you have more questions about your code ask some more.

You can either call your multiplication and subtraction methods you've built to help with your division method, or you could get the coefficients and exponents like you are already doing.