?
Solved

Linked List

Posted on 2006-07-04
3
Medium Priority
?
2,451 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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

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…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to use and create keystrokes in Netbeans IDE 8.0 for Windows.
The viewer will learn how to synchronize PHP projects with a remote server in NetBeans IDE 8.0 for Windows.
Suggested Courses

770 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