Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Linked List

Posted on 2006-07-04
3
Medium Priority
?
2,453 Views
Last Modified: 2013-12-14
create a Linked list to represent the following polynomial
3*x^2*y   +   9x*y^3   +   15*x*y   +  3

I not able to figure out how to proceed with this question...


0
Comment
Question by:sinha_anshul26
[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
3 Comments
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 600 total points
ID: 17040555
>>>> I not able to figure out how to proceed with this question...

You need to parse the given algorithm, extracting each token. You should get a list like

3  number
*  mul
x  variable
^  pow
*  number
y  variable
+  add


The first column type is string cause you might get names and/numbers.

The second could be a enum, e. g.

  enum MathToken { NUMBER, VARIABLE, MUL, POW, ADD, ... };

Any 'row' of the above list can be set to a new item, combining both attributes:

  struct Token
  {
        string        value;
        MathToken token;
  };

Then, you may put the items to a linked list, e. g.

   list<Token> polynomial;

e. g. by using std::list  which you get by

 #include <list>
 using namespace std;

Regards, Alex






0
 
LVL 17

Assisted Solution

by:rstaveley
rstaveley earned 200 total points
ID: 17040573
I guess you can express each term of the polynomal as a node in a linked list. The coefficient and x and y exponents as members.

e.g.

struct Term {int coeff;int xexp;int yexp;}
typedef std::list<Term> Polynomial;

However, I expect you aren't allowed to use the standard library for your linked list in your assignment.
0
 
LVL 5

Assisted Solution

by:dennis_george
dennis_george earned 200 total points
ID: 17040637
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Many modern programming languages support the concept of a property -- a class member that combines characteristics of both a data member and a method.  These are sometimes called "smart fields" because you can add logic that is applied automaticall…
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.

618 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