Discussion:
Question
(too old to reply)
prashant
2005-02-20 02:32:17 UTC
Permalink
I was just wondering about this. The getCoefficient function states that
"This must run in O(n) time where n is the number of NON-ZERO coefficients"

This means we only store the non zero terms in our linked list (makes
sence), but this also means that we have to manipulate the LinkedList's
inner class (Element class) to include one more object.

Mainly Element class will have 3 feilds
1). Rational coefficient (value that it carries)
2). int power (the power it is associated to)
3). Element next (the next Element)

Is this correct?? or are we NOT allowed to change the Element class and
think of another way to solve the problem.

Thanks
- Prashant
Adam Bertrand
2005-02-21 08:15:44 UTC
Permalink
I don't see why this is a bad course of action...
Post by prashant
I was just wondering about this. The getCoefficient function states that
"This must run in O(n) time where n is the number of NON-ZERO coefficients"
This means we only store the non zero terms in our linked list (makes
sence), but this also means that we have to manipulate the LinkedList's
inner class (Element class) to include one more object.
Mainly Element class will have 3 feilds
1). Rational coefficient (value that it carries)
2). int power (the power it is associated to)
3). Element next (the next Element)
Is this correct?? or are we NOT allowed to change the Element class and
think of another way to solve the problem.
Thanks
- Prashant
Prashant
2005-02-21 15:21:50 UTC
Permalink
No no. i didn't mean to ask if this "was a bad course of action" or not.
what i meant to ask was are we allowed to modify the Linked list class or
not? because i think the problem "can"(not too sure) be solved withour
changing the linked list file but it will be too much work then just
changing the Linked list class. (also we are instructed to use the same
linked list in project 4)

So could one of the TA's or the Instructor please clarify on this point.

Thank you.
- Prashant
Post by Adam Bertrand
I don't see why this is a bad course of action...
Post by prashant
I was just wondering about this. The getCoefficient function states that
"This must run in O(n) time where n is the number of NON-ZERO coefficients"
This means we only store the non zero terms in our linked list (makes
sence), but this also means that we have to manipulate the LinkedList's
inner class (Element class) to include one more object.
Mainly Element class will have 3 feilds
1). Rational coefficient (value that it carries)
2). int power (the power it is associated to)
3). Element next (the next Element)
Is this correct?? or are we NOT allowed to change the Element class and
think of another way to solve the problem.
Thanks
- Prashant
Loading...