prashant
2005-02-20 02:32:17 UTC
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
"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