Discussion:
Project 3 Question
(too old to reply)
Luc Gallant
2004-11-01 00:52:12 UTC
Permalink
I had a question about project 3. My question is: For the LinkedList
class, I understand that we are allowed to use the one in the text book.
This is fine. Now, for the element class, that class has only one Object
in it, which is no sufficient for the coefficient and the order. What I
want to know is, should we just create a double and an integer instead of
the Object, and by that consequence modify the Element class, or should we
create a class like " aTerm " which would be and Object in the Element?
From what I think, we should be just using the Element itself to store the
coefficient and the order, but I don't know if this is acceptable.

Luc
Igor Ivkovic
2004-11-04 12:43:00 UTC
Permalink
Post by Luc Gallant
I had a question about project 3. My question is: For the LinkedList
class, I understand that we are allowed to use the one in the text book.
This is fine. Now, for the element class, that class has only one Object
in it, which is no sufficient for the coefficient and the order. What I
want to know is, should we just create a double and an integer instead of
the Object, and by that consequence modify the Element class, or should we
create a class like " aTerm " which would be and Object in the Element?
From what I think, we should be just using the Element itself to store the
coefficient and the order, but I don't know if this is acceptable.
The easiest solution is to update the Element class to fit the P3 specs
and then use it within your linked list implementation class.

Igor
Post by Luc Gallant
Luc
Igor Ivkovic
2004-11-07 20:14:06 UTC
Permalink
With a slight delay, let me clarify as a lot of you are having problems...

If you know that you got an instance of PolynomialAsLinkedList, then you
need to purge "this" polynomial and then iterate through and assign
elements of the passed in polynomial using LinkedList "assign" method
(i.e., access both linked lists directly).

If you know that you did NOT get an instance of PolynomialAsLinkedList,
then you need to purge "this" polynomial and then iterate through elements
of the passed in polynomial using getCoefficient and use LinkedList
"append" method to assign the elements (i.e., access only the linked list
of "this" polynomial directly and access other data struct indirectly).

The former's estimated running time is O(m) and the later is O(M). Note
that we are not using SetCofficient here, so the running time of O(n)
required for regular calls to SetCoefficient will not apply.

Similar discussion holds for other methods such as plus, minus, etc.

Igor
I have a question about the "assign" method. It says in the requirement
that the running time should be O(m) or O(M), I don't quite understand
it. For my current implementation, I am using the getDegree and
setCoefficient methods of the polynomial interface to implement the
assign method.
However, the running time of both cases would be m*O(n) or M*O(n). What is
wrong with my thought process? Any help would be greatly appreciated.
Thanks,
Robert Xu
----------------------------------------
This mail sent through www.mywaterloo.ca
Continue reading on narkive:
Loading...