0

I'm currently working on a project that calculates polynomial expressions (We got this for a task at University). I'm storing a polynomial in a linked list and I've overloaded operators +,*,-,' for polynomials. The most difficult task that I've got is to parse an expression like this e.g. : (3x-(-x-1)^2)(x^3-2x^2+1)''where '' is second derivative. I've been googling a lot and couldn't find antyhing that could parse and make an postfix expression out of this when you have a variable x and numbers, is there a way to modify Shunting-Yard algorithm so that it could work on polynomials?

My node stores coefficient, power, pointer to the previous and next node and my Polynomial class supports every operation thats stated above. The only problem is how can I get a postfix expression out of a string that I put above? Btw. only '(' & ')' parentheses are supported, that makes it a bit easier.

For the example (3x-(-x-1)^2)(x^3-2x^2+1)'' I need to store the result of it in a polynomial that I made.

I can provide more if asked, Thanks in advance!

  • There's pseudocode [in this answer] which shows how to use a simple two-state state machine to handle prefix and postfix operators. It doesn't do the invisible multiplication operator, though it can be handled in – rici Dec 15 '19 at 22:19
  • Sorry, my link doesn't seem to have worked. The pseudocode is in this answer: https://stackoverflow.com/a/16392115/1566221 – rici Dec 16 '19 at 00:41

0 Answers0