











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 and Algorithm are Permutation, Representation, Implemented, Algorithm Design, Dynamic Programming, Graph Data Structures, String Processing, General Trees. Main points of this lecture are: Arrays, Pairs, Each Index, Data Structure, Representation, Implemented, Using Consecutive, Consecutive Memory, Value Associated, Notations
Typology: Slides
1 / 19
This page cannot be seen from the preview
Don't miss anything!












en n
1
Objects : a set of ordered pairs of <e (^) i ,ai> where ai in Coefficients and ei in Exponents, ei are integers >= 0 Methods: for all poly, poly1, poly2 ∈ Polynomial, coef ∈Coefficients, expon ∈Exponents Polynomial Zero( ) ::= return the polynomial p(x) = 0 Boolean IsZero(poly) ::= if (poly) return FALSE else return TRUE Coefficient Coef(poly, expon) ::= if (expon ∈ poly) return its coefficient else return Zero Exponent Lead_Exp(poly) ::= return the largest exponent in poly Polynomial Attach(poly,coef, expon) ::= if (expon ∈ poly) return error else return the polynomial poly with the term <coef, expon> inserted
#define MAX_DEGREE 101 typedef struct { int degree; float coef[MAX_DEGREE]; } polynomial;
polynomials
2 1 1 10 3 1
1000 0 4 3 2 0
col1 col2 col3 col4 col5 col row row row row row row
Objects: a set of triples, <row, column, value>, where row and column are integers and form a unique combination, and value comes from the set item.
Methods :
Sparse_Marix Create(max_row, max_col) ::= return a Sparse_matrix that can hold up to
whose maximum row size is max_row and whose maximum column size is max_col.
Sparse_matrix Create(max_row, max_col) ::=
#define MAX_TERMS 101 /* maximum number of terms +1*/ typedef struct { int col; int row; int value; } term; term A[MAX_TERMS]
row col value row col value a[0] 6 6 8 b[0] 6 6 8 [1] 0 0 15 [1] 0 0 15 [2] 0 3 22 [2] 0 4 91 [3] 0 5 -15 [3] 1 1 11 [4] 1 1 11 [4] 2 1 3 [5] 1 2 3 [5] 2 5 28 [6] 2 3 -6 [6] 3 0 22 [7] 4 0 91 [7] 3 2 - [8] 5 2 28 [8] 5 0 -
void transpose (term a[], term b[]) /* b is set to the transpose of a / { int n, i, j, currentb; n = a[0].value; / total number of elements / b[0].row = a[0].col; / rows in b = columns in a / b[0].col = a[0].row; /columns in b = rows in a / b[0].value = n; if (n > 0) { /non zero matrix / currentb = 1; for (i = 0; i < a[0].col; i++) / transpose by columns in a / for( j = 1; j <= n; j++) / find elements from the current column / if (a[j].col == i) { / element is in current column, add it to b */ Docsity.com