linked list - Array Representation of Polynomials -


It is said that I was reading about the linked list implementation of polynomials,

  Compare this representation with the addition of the same polynomial by using the array structure. In the array, we have to put a slot for each exponent of X, so if we have a polynomial of 50, but there will be only 6 words, then a large number of entries will be zero in the array.   

I was wondering how do we represent a polynomial in an array? Please guide me

Thanks

A complete Java implementation of array based polynomials is here: / P>

The basic idea is that if you have a polynomial

  4x ^ 6-2x + 5   

then your array will look like this

  0 1 2 3 4 5 6 + ---- + ----- + ---- + ---- + ---- + - --- + - --- + | 5 | -2 | 0 | 0 | 0 | 0 | 4 | + ---- + ----- + ---- + ---- + ---- + ---- + ---- +   

This is

  • Coefficient 5 is in slot 0 of the array (representing 5x ^ 0)
  • Coefficient 2 is in slot 1 of array (representing -2x ^ 1)
  • The coefficient 4 is in slot 6 of the array (representing 4x ^ 6)

    You can probably see how this representative would be useless for polynomials. / P>

      3x ^ 5000 + 2   

    In such cases, instead of using an space array representation Want to receive the easiest way would be to use a map (dictionary) the keys exponoents and whose value coefficient.

Comments

Popular posts from this blog

mysql - BLOB/TEXT column 'value' used in key specification without a key length -

c# - Using Vici cool Storage with monodroid -

python - referencing a variable in another function? -