















Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Some concept of Data Structures are Abstract, Balance Factor, Complete Binary Tree, Dynamically, Storage, Implementation, Sequential Search, Advanced Data Structures, Graph Coloring Two, Insertion Sort. Main points of this lecture are: Polynomial, Recall, Single Variable, Highest Exponent, Abstract Data Type, Single Variable Polynomial, Generalized, Expanded, Visible Data Sets, Object
Typology: Slides
1 / 23
This page cannot be seen from the preview
Don't miss anything!
















An example of a single variable polynomial:
4x^6 + 10x^4 - 5x + 3
Remark: the order of this polynomial is 6 (look for highest exponent)
…This sum can be expanded to:
a n x n^ + a (n-1) x (n-1)^ + … + a 1 x^1 + a 0
Notice the two visible data sets namely: (C and E), where
By definition of a data types:
A set of values and a set of allowable operations on those values.
We can now operate on this polynomial the way we like…
Calculating polynomial operations by hand can be very cumbersome. Take differentiation as an example:
d(23x^9 + 18x^7 + 41x^6 + 163x^4 + 5x + 3)/dx
= (239)x (9-1)^ + (187)x (7-1)^ + (41*6)x (6-1)^ + …
There are different ways of implementing the polynomial ADT:
6 2 0 0 -3 0 ………… 0 16
WASTE OF SPACE!
23 18 -41 163 -5 3 4 10 12 8 9 7 6 4 1 0 6 4 1 0
Coefficient
Exponent
Start p1(x) Start p2(x)
End p1(x) End p2(x)
(^0 2 )
To do this, we have to break the process down to cases:
4x^3 + 10x^2 + 5x + 3
4x^3 + 10x^2 + 5x + 3
A general (and inefficient ) algorithm:
int Poly = 0; int Multiply; for (int i=0; i < a.Size; i++) { Multiply =1; for (int j=0; j<i; j++) { Multiply = x; } Poly += ma[i]; }
i j Poly 0 0 3 1 0 5x + 3 2 0 10x + 5x + 1 10x 2 + 5x + 3 3 0 4x + 10x 2 + 5x + 3 1 4x 2 + 10x 2 + 5x + 3
Time Complexity O(n^2 )^2 4x^3 + 10x^2 + 5x + 3