Solved

Linked List

Posted on 2006-07-04
3
2,447 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
3 Comments
 
LVL 39

Accepted Solution

by:
itsmeandnobodyelse earned 150 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 50 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 50 total points
ID: 17040637
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
How to copy an image file into clipboard C/C++? 1 168
is twain_32.dll cmpatible with windows 10 ? 10 161
Create a path if not exists 7 77
How do i run a c++ file? 15 27
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…
Update (December 2011): Since this article was published, the things have changed for good for Android native developers. The Sequoyah Project (http://www.eclipse.org/sequoyah/) automates most of the tasks discussed in this article. You can even fin…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

776 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