SlideShare a Scribd company logo
1 of 25
TITLE :DATA STRUCTURE AND ALGORITHM
STAF NAME :MS.MANIMOZHI,MCA.,M.PHIL.,(PH.D)
CLASS :III BCA
SEMSTER :V
UNIT :I
..
Data structure and algorithm
Array and list
CONTENTS
• Array
• Uses of array
• Ordered list
• Sparse matrix
• Linked list
• Singly linked list
• Polynomial
ARRAYS
Array:
a set of pairs (index and value)
Data structure
For each index, there is a value associated with that index.
Representation (possible)
implemented by using consecutive memory.
USES OF ARRAY
An array is used to store a fixed number of data elements of the
same data type.
A single block of memory is set aside to store the whole array.
Arrays are the most commonly used data structure and as such are
directly included within most programming languages.
An example array, called Numbers, storing five integers.
ARRAYS IN C++
int list[5], *plist[5];
list[5]: five integers
list[0], list[1], list[2], list[3], list[4]
*plist[5]: five pointers to integers
plist[0], plist[1], plist[2], plist[3], plist[4]
implementation of 1-D array
list[0] base address = 
list[1]  + sizeof(int)
list[2]  + 2*sizeof(int)
list[3]  + 3*sizeof(int)
list[4]  + 4*size(int)
ARRAYS IN C++
• Compare int *list1 and int list2[5] in C++.
Same: list1 and list2 are pointers.
Difference: list2 reserves five locations.
• Notations:
list2 - a pointer to list2[0]
(list2 + i) - a pointer to list2[i] (&list2[i])
*(list2 + i) - list2[i]
EXAMPLE
#include <iostream>
void print1(int *ptr, int rows)
{
int i;
cout << "Address Contents" << endl;
for (i=0; i < rows; i++)
cout << ptr+i << " " << *(ptr+i) << endl;
}
void main(){
int one[] = {0, 1, 2, 3, 4}; //Goal: print out address and value
print1(one, 5);
}
C++ OBJECTS
Objects:
A set of pairs <index, value> where for each value of index
there is a value from the set item.
Index is a finite ordered set of one or more dimensions, for example,
{0, … , n-1} for one dimension,
{(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)} for two dimensions,
etc
C++ METHODS
Methods:
for all A  Array, i  index, x  item, j, size  integer
Array Create(j, list) ::= return an array of j dimensions where list is a
j-tuple whose kth element is the size of the
kth dimension. Items are undefined.
Item Retrieve(A, i) ::= if (i  index) return the item associated with
index value i in array A
else return error
Array Store(A, i, x) ::= if (i in index)
return an array that is identical to array
A except the new pair <i, x> has been
inserted else return error
OTHER DATA STRUCTURE BASED
ON ARRAY
Arrays:
o Basic data structure
o May store any type of elements
Polynomials:
o defined by a list of coefficients and exponents
o degree of polynomial = the largest exponent in a polynomial
ORDERED LIST
One of the simplest and most commonly found data object is the ordered
or linear
SPARSE MATRIX
A matrix is a mathematical object which arises in many physical
problems
SPARSE MATRIX ADT
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
for all a, b  Sparse_Matrix, x  item, i, j, max_col, max_row  index
Sparse Marix Create(max_row, max_col) ::=
return a Sparse_matrix that can hold up to
max_items = max _row  max_col and
whose maximum row size is max_row and
whose maximum column size is max_col.
•
Sparse_Matrix Transpose(a) ::=
return the matrix produced by interchanging
the row and column value of every triple.
Sparse_Matrix Add(a, b) ::=
if the dimensions of a and b are the same
return the matrix produced by adding
corresponding items, namely those with
identical row and column values.
else return error
Sparse_Matrix Multiply(a, b) ::=
if number of columns in a equals number of rows in b
return the matrix d produced by multiplying
a by b according to the formula: d [i] [j] =
(a[i][k]•b[k][j]) where d (i, j) is the (i,j)th
element
else return error.
SPARSE MATRIX REPRESENTATION
Represented by a two-dimensional array.
Sparse matrix wastes space.
Each element is characterized by <row, col, value>.
• The terms in A should be ordered
• based on <row, col>
LINKED LIST
The representation of the simple data structure using array and
a sequential mapping
Avoid the drawbacks of fixed size arrays with
• Growable arrays
• Linked lists
GROWABLE ARRAY
Avoid the problem of fixed-size arrays
Increase the size of the array when needed (I.e. when capacity
is exceeded)
Two strategies:
• tight strategy (add a constant): f(N) = N + c
• growth strategy (double up): f(N) = 2N
SINGLY LINKED LIST
A singly linked list is a concrete data structure consisting of a
series of nodes
Each node stores
• Data item
• Link to the next node
IMPLEMENT A LINKED LIST
• Single Linked List (.h, .cpp, test program)
• Double Linked List (.h, .cpp, test program)
POLYNOMIAL ADDISTION
• Use an array to keep track of the coefficients for all exponents
• A(X)=2X1000+1
• B(X)=X4+10X3+3X2+1
POLYNOMIAL ADP
Objects: a set of ordered pairs of <ei, 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(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
Polynomial Remove(poly, expon) ::= if (expon  poly) return the
polynomial poly with the term
whose exponent is expon deleted
else return error
Polynomial SingleMult(poly, coef, expon)::= return the polynomial
poly • coef • xexpon
Polynomial Add(poly1, poly2) ::= return the polynomial
poly1 +poly2
Polynomial Mult(poly1, poly2) ::= return the polynomial
poly1 • poly2
LINKED LIST VS ARRAY
 Linked list can be easily expanded or reduced; Array needs a
contiguous memory space and may not even be possible to resize.
 Insertion and deletion in linked list are O(1) while it takes O(n) for
array.
 Array allow random access and the indexing of an array takes O(1).
 The sequential access with linked list makes it more expensive in
indexing, which takes O(n)

More Related Content

What's hot (20)

Arrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | EdurekaArrays In Python | Python Array Operations | Edureka
Arrays In Python | Python Array Operations | Edureka
 
Array
ArrayArray
Array
 
Arrays & Strings
Arrays & StringsArrays & Strings
Arrays & Strings
 
Lecture 6 - Arrays
Lecture 6 - ArraysLecture 6 - Arrays
Lecture 6 - Arrays
 
Programming in c Arrays
Programming in c ArraysProgramming in c Arrays
Programming in c Arrays
 
Algorithms notes tutorials duniya
Algorithms notes   tutorials duniyaAlgorithms notes   tutorials duniya
Algorithms notes tutorials duniya
 
Array
ArrayArray
Array
 
C programming , array 2020
C programming , array 2020C programming , array 2020
C programming , array 2020
 
Introduction to Array ppt
Introduction to Array pptIntroduction to Array ppt
Introduction to Array ppt
 
Arrays
ArraysArrays
Arrays
 
C++ Arrays
C++ ArraysC++ Arrays
C++ Arrays
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]Data Structures - Lecture 3 [Arrays]
Data Structures - Lecture 3 [Arrays]
 
C++ lecture 04
C++ lecture 04C++ lecture 04
C++ lecture 04
 
Python data handling notes
Python data handling notesPython data handling notes
Python data handling notes
 
Arrays in c
Arrays in cArrays in c
Arrays in c
 
List , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in pythonList , tuples, dictionaries and regular expressions in python
List , tuples, dictionaries and regular expressions in python
 
An Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using HaskellAn Introduction to Functional Programming using Haskell
An Introduction to Functional Programming using Haskell
 
2-D array
2-D array2-D array
2-D array
 
Hashing
HashingHashing
Hashing
 

Similar to Data Structures and Algorithms Explained

Similar to Data Structures and Algorithms Explained (20)

Array
ArrayArray
Array
 
Arrays
ArraysArrays
Arrays
 
Built-in Classes in JAVA
Built-in Classes in JAVABuilt-in Classes in JAVA
Built-in Classes in JAVA
 
Java10 Collections and Information
Java10 Collections and InformationJava10 Collections and Information
Java10 Collections and Information
 
Cliff tip indexmatch_01
Cliff tip indexmatch_01Cliff tip indexmatch_01
Cliff tip indexmatch_01
 
Built in classes in java
Built in classes in javaBuilt in classes in java
Built in classes in java
 
Chap09
Chap09Chap09
Chap09
 
Java: Introduction to Arrays
Java: Introduction to ArraysJava: Introduction to Arrays
Java: Introduction to Arrays
 
Python programming : Arrays
Python programming : ArraysPython programming : Arrays
Python programming : Arrays
 
9781439035665 ppt ch09
9781439035665 ppt ch099781439035665 ppt ch09
9781439035665 ppt ch09
 
Homework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdfHomework Assignment – Array Technical DocumentWrite a technical .pdf
Homework Assignment – Array Technical DocumentWrite a technical .pdf
 
DSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notesDSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notes
 
Chapter2
Chapter2Chapter2
Chapter2
 
ARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptxARRAY OPERATIONS.pptx
ARRAY OPERATIONS.pptx
 
Power of functions in a typed world
Power of functions in a typed worldPower of functions in a typed world
Power of functions in a typed world
 
Algorithm and Programming (Array)
Algorithm and Programming (Array)Algorithm and Programming (Array)
Algorithm and Programming (Array)
 
Array properties
Array propertiesArray properties
Array properties
 
Statistics lab 1
Statistics lab 1Statistics lab 1
Statistics lab 1
 
19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt19-Lec - Multidimensional Arrays.ppt
19-Lec - Multidimensional Arrays.ppt
 
Introduction to R
Introduction to RIntroduction to R
Introduction to R
 

Recently uploaded

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Disha Kariya
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 

Recently uploaded (20)

The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Advance Mobile Application Development class 07
Advance Mobile Application Development class 07Advance Mobile Application Development class 07
Advance Mobile Application Development class 07
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..Sports & Fitness Value Added Course FY..
Sports & Fitness Value Added Course FY..
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 

Data Structures and Algorithms Explained

  • 1. TITLE :DATA STRUCTURE AND ALGORITHM STAF NAME :MS.MANIMOZHI,MCA.,M.PHIL.,(PH.D) CLASS :III BCA SEMSTER :V UNIT :I ..
  • 2. Data structure and algorithm Array and list
  • 3. CONTENTS • Array • Uses of array • Ordered list • Sparse matrix • Linked list • Singly linked list • Polynomial
  • 4. ARRAYS Array: a set of pairs (index and value) Data structure For each index, there is a value associated with that index. Representation (possible) implemented by using consecutive memory.
  • 5. USES OF ARRAY An array is used to store a fixed number of data elements of the same data type. A single block of memory is set aside to store the whole array. Arrays are the most commonly used data structure and as such are directly included within most programming languages. An example array, called Numbers, storing five integers.
  • 6. ARRAYS IN C++ int list[5], *plist[5]; list[5]: five integers list[0], list[1], list[2], list[3], list[4] *plist[5]: five pointers to integers plist[0], plist[1], plist[2], plist[3], plist[4] implementation of 1-D array list[0] base address =  list[1]  + sizeof(int) list[2]  + 2*sizeof(int) list[3]  + 3*sizeof(int) list[4]  + 4*size(int)
  • 7. ARRAYS IN C++ • Compare int *list1 and int list2[5] in C++. Same: list1 and list2 are pointers. Difference: list2 reserves five locations. • Notations: list2 - a pointer to list2[0] (list2 + i) - a pointer to list2[i] (&list2[i]) *(list2 + i) - list2[i]
  • 8. EXAMPLE #include <iostream> void print1(int *ptr, int rows) { int i; cout << "Address Contents" << endl; for (i=0; i < rows; i++) cout << ptr+i << " " << *(ptr+i) << endl; } void main(){ int one[] = {0, 1, 2, 3, 4}; //Goal: print out address and value print1(one, 5); }
  • 9. C++ OBJECTS Objects: A set of pairs <index, value> where for each value of index there is a value from the set item. Index is a finite ordered set of one or more dimensions, for example, {0, … , n-1} for one dimension, {(0,0),(0,1),(0,2),(1,0),(1,1),(1,2),(2,0),(2,1),(2,2)} for two dimensions, etc
  • 10. C++ METHODS Methods: for all A  Array, i  index, x  item, j, size  integer Array Create(j, list) ::= return an array of j dimensions where list is a j-tuple whose kth element is the size of the kth dimension. Items are undefined. Item Retrieve(A, i) ::= if (i  index) return the item associated with index value i in array A else return error Array Store(A, i, x) ::= if (i in index) return an array that is identical to array A except the new pair <i, x> has been inserted else return error
  • 11. OTHER DATA STRUCTURE BASED ON ARRAY Arrays: o Basic data structure o May store any type of elements Polynomials: o defined by a list of coefficients and exponents o degree of polynomial = the largest exponent in a polynomial
  • 12. ORDERED LIST One of the simplest and most commonly found data object is the ordered or linear
  • 13. SPARSE MATRIX A matrix is a mathematical object which arises in many physical problems
  • 14. SPARSE MATRIX ADT 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.
  • 15. • Methods for all a, b  Sparse_Matrix, x  item, i, j, max_col, max_row  index Sparse Marix Create(max_row, max_col) ::= return a Sparse_matrix that can hold up to max_items = max _row  max_col and whose maximum row size is max_row and whose maximum column size is max_col.
  • 16. • Sparse_Matrix Transpose(a) ::= return the matrix produced by interchanging the row and column value of every triple. Sparse_Matrix Add(a, b) ::= if the dimensions of a and b are the same return the matrix produced by adding corresponding items, namely those with identical row and column values. else return error Sparse_Matrix Multiply(a, b) ::= if number of columns in a equals number of rows in b return the matrix d produced by multiplying a by b according to the formula: d [i] [j] = (a[i][k]•b[k][j]) where d (i, j) is the (i,j)th element else return error.
  • 17. SPARSE MATRIX REPRESENTATION Represented by a two-dimensional array. Sparse matrix wastes space. Each element is characterized by <row, col, value>. • The terms in A should be ordered • based on <row, col>
  • 18. LINKED LIST The representation of the simple data structure using array and a sequential mapping Avoid the drawbacks of fixed size arrays with • Growable arrays • Linked lists
  • 19. GROWABLE ARRAY Avoid the problem of fixed-size arrays Increase the size of the array when needed (I.e. when capacity is exceeded) Two strategies: • tight strategy (add a constant): f(N) = N + c • growth strategy (double up): f(N) = 2N
  • 20. SINGLY LINKED LIST A singly linked list is a concrete data structure consisting of a series of nodes Each node stores • Data item • Link to the next node
  • 21. IMPLEMENT A LINKED LIST • Single Linked List (.h, .cpp, test program) • Double Linked List (.h, .cpp, test program)
  • 22. POLYNOMIAL ADDISTION • Use an array to keep track of the coefficients for all exponents • A(X)=2X1000+1 • B(X)=X4+10X3+3X2+1
  • 23. POLYNOMIAL ADP Objects: a set of ordered pairs of <ei, 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(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
  • 24. Polynomial Remove(poly, expon) ::= if (expon  poly) return the polynomial poly with the term whose exponent is expon deleted else return error Polynomial SingleMult(poly, coef, expon)::= return the polynomial poly • coef • xexpon Polynomial Add(poly1, poly2) ::= return the polynomial poly1 +poly2 Polynomial Mult(poly1, poly2) ::= return the polynomial poly1 • poly2
  • 25. LINKED LIST VS ARRAY  Linked list can be easily expanded or reduced; Array needs a contiguous memory space and may not even be possible to resize.  Insertion and deletion in linked list are O(1) while it takes O(n) for array.  Array allow random access and the indexing of an array takes O(1).  The sequential access with linked list makes it more expensive in indexing, which takes O(n)