Article View: alt.comp.lang.learn.c-c++
Article #230Please help me!!
From: Brian McSweeney
Date: Tue, 03 Mar 1998 00:00
Date: Tue, 03 Mar 1998 00:00
60 lines
3033 bytes
3033 bytes
--------------1A172F2E77FFC744E4C8027F
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Poor student studying for a scholarship exam in a week!!
I want to know how (as simply as possible) to insert objects into a
linked list.
Example question:
"Define a linked list that can represent a polynomial. Then write a
method to add on another polynomial (ie link them) to the current one,
and a method to add the one polynomial to another."
Now I know how to define the linked list - a class that has an exponent
and a coefficient and a pointer to objects of that class, and I know how
to create the list. I also know that to add on another linked list to
the current one you just traverse the first list and then set its end
pointer to the pointer to the start of the second list.
But how do you do the add method? the exponent term of one may be
different to that of the other and in that case it will have to be
inserted somehow??
eg. (3x^2 +2x^5) + (2x + x^3+x^5) = 2x+3x^2+x^3+3x^5
I am so grateful to you if you can reply to me at
"mcsweeenb@tcd.ie"
--------------1A172F2E77FFC744E4C8027F
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit
<HTML>
Poor student studying for a scholarship exam in a week!!
<P>I want to know how (as simply as possible) to insert objects into a
linked list.
<P>Example question:
<P>"Define a linked list that can represent a polynomial. Then write
a method to add <U>on</U> another polynomial (ie link them) to the current
one, and a method to add the one polynomial to another."
<P>Now I know how to define the linked list - a class that has an exponent
and a coefficient and a pointer to objects of that class, and I know how
to create the list. I also know that to add on another linked list
to the current one you just traverse the first list and then set its end
pointer to the pointer to the start of the second list.
<BR> But how do you do the add method? the
exponent term of one may be different to that of the other and in that
case it will have to be inserted somehow??
<BR>eg. (3x^2 +2x^5) + (2x + x^3+x^5) = 2x+3x^2+x^3+3x^5
<P>I am so grateful to you if you can reply to me at
<BR>"mcsweeenb@tcd.ie" </HTML>
--------------1A172F2E77FFC744E4C8027F--
Technical Details
Message-ID:
<34FC5E36.252831A1@tcd.ie>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10d4ba,7edcd2b95cb2575c,start X-Google-Attributes: gid10d4ba,public X-Google-Thread: 114592,7edcd2b95cb2575c,start X-Google-Attributes: gid114592,public X-Google-Thread: 109fba,7edcd2b95cb2575c,start X-Google-Attributes: gid109fba,public From: Brian McSweeney <mcsweenb@tcd.ie> Subject: Please help me!! Date: 1998/03/03 Message-ID: <34FC5E36.252831A1@tcd.ie> X-Deja-AN: 330503035 Content-Type: multipart/alternative; boundary="------------1A172F2E77FFC744E4C8027F" Organization: Ireland On-Line Mime-Version: 1.0 Newsgroups: alt.comp.lang.learn.c-c++,att.lang.c++,comp.lang.c++