Solved

polynomial.cpp

Posted on 2003-11-09
7
1,986 Views
Last Modified: 2008-05-31
Hi! I have to create a program with linked list that can,
create a new polynomial object
add a polynomial to current polynomial object
multiply the current polynomial object by another polynom
multiply the current polynomial object by an integer constant
evaluate the current polynomial object at a given number
find the first derivative of the polynomial
print out like p(x)=5x^10 + 9x^7 - x - 10

I am waitin for your help
If you have a similar program pls send it
   
0
Comment
Question by:sbeolrian
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 6

Expert Comment

by:GaryFx
ID: 9709631
This sounds like homework.  
0
 
LVL 11

Accepted Solution

by:
bcladd earned 43 total points
ID: 9709854
GaryFx is right. We can help you with specific problems on homework.

That said, I can offer some high-level design guidance:

You will want to think about what you will link together. In a polynomial, what are there a variable number of? Seems like the answer is terms:

3x^2 + 2x + 1

4x^5 + 2x

Two different polynomials, one with three terms and one with two terms. Since the number of terms is unknown (that is it varies for each polynomial), this is a good candidate for a linked list. One thing to note about adding or evaluating polynomials  is that it is nice when the terms are ordered by the exponent.

Okay, part of the answer is exposed but what IS a term? Each term has a power of x, an exponent. What is the TYPE of the exponent? Each term also multiplies the power of x by some value, the coefficient.  What is the TYPE of the coefficient.

So, the polynomial class must encapsulate a linked list of terms.  I would suggest you start with a constructor, destructor, and a routine for printing the contents of a polynomial. That way you can test your program before you work on the other operations. Remember to compile early and often and fix the first bug first.

Good luck, -bcl
0
 
LVL 3

Assisted Solution

by:Sandra-24
Sandra-24 earned 41 total points
ID: 9711103
If you need ideas or help creating your linked list:

http://www.fortunecity.com/skyscraper/false/780/linklist.html

http://www.inversereality.org/tutorials/c++/linkedlists.html

http://www.gla55pak.com/lameduckie/02may/listtutorial/

You'll also find a heck of a lot of info in Google on this, including the full code to just about any sort of linked list if you look in the right places.

-Sandra
0
[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

 
LVL 8

Assisted Solution

by:Exceter
Exceter earned 41 total points
ID: 9715010
>> If you need ideas or help creating your linked list:

I wouldn't write a container, just use the STL containers. You parse the polynomial into its individual terms and use either std::list<std::string> or std::vector<std::string> to store the terms.

Exceter
0
 
LVL 11

Expert Comment

by:bcladd
ID: 9715047
Exceter-

Excellent suggestion but this program is typically assigned to give the student practice with making their own linked list (at least I usually assign it that way  and most of the intro CS texts I have read that include it use as an example or an assignment when describing linked lists). Thus using the STL containers is _probably_ not an option for the original poster but is certainly the right way to go if one wants to implement polynomials as painlessly as possible.

-bcl
0
 
LVL 9

Expert Comment

by:tinchos
ID: 10248825
No comment has been added lately, so it's time to clean up this TA.
I will leave the following recommendation for this question in the Cleanup topic area:

Split: bcladd {http:#9709854} & Sandra-24 {http:#9711103} & Exceter {http:#9715010}

Please leave any comments here within the next seven days.
PLEASE DO NOT ACCEPT THIS COMMENT AS AN ANSWER!

Tinchos
EE Cleanup Volunteer
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

623 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question