SlideShare a Scribd company logo
Data Structures and Algorithms
UNIT-II-List Structure
Syllabus
Operations on List ADT – Create, Insert, Search, Delete, Display
elements; Implementation of List ADT – Array, Cursor based and
Linked Types – Singly, Doubly, Circular; Applications - Sparse Matrix,
Polynomial Arithmetic, Joseph Problem
Operations on List ADT
ADT = properties + operations
• An ADT describes a set of objects sharing the same properties and
behaviors
• The properties of an ADT are its data (representing the internal state of each
object
• double d; -- bits representing exponent & mantissa are its data or state
• The behaviors of an ADT are its operations or functions (operations on each
instance)
• sqrt(d) / 2; //operators & functions are its behaviors
The List ADT
 A sequence of zero or more elements A1, A2, A3, … AN
 N: length of the list
 A1: first element
 AN: last element
 Ai: position i
 If N=0, then empty list
 Linearly ordered
 Ai precedes Ai+1
 Ai follows Ai-1
Operations
 makeEmpty: create an empty list
 find: locate the position of an object in a list
 list: 34,12, 52, 16, 12
 find(52)  3
 insert: insert an object to a list
 insert(x,3)  34, 12, 52, x, 16, 12
 remove: delete an element from the list
 remove(52)  34, 12, x, 16, 12
 findKth: retrieve the element at a certain position
 printList: print the list
Implementation of an ADT
• Choose a data structure to represent the ADT
• E.g. arrays, records, etc.
• Each operation associated with the ADT is implemented by one or
more subroutines
• Two standard implementations for the list ADT
• Array-based
• Linked list
Array Implementation
• Elements are stored in contiguous array positions
1D Array Representation
• 1-dimensional array x = [a, b, c, d]
• map into contiguous memory locations
2D Arrays
• The elements of a 2-dimensional array a declared as:
int a[3][4] ;
• may be shown as a table
a[0][0] a[0][1] a[0][2] a[0][3]
a[1][0] a[1][1] a[1][2] a[1][3]
a[2][0] a[2][1] a[2][2] a[2][3]
2D Array Representation
Linear List Array Representation
• use a one-dimensional array called alphabet[]
• List = (a, b, c, d, e)
• Store element I of list in alphabet[i]
To add an element
To remove an element
Array Applications
• Stores Elements of Same Data Type
• Array Used for Maintaining multiple variable names using single name
• Array Can be Used for Sorting Elements
• Array Can Perform Matrix Operation
• Array Can be Used in CPU Scheduling
• Array Can be Used in Recursive Function
Array Implementation...
🞂 Requires an estimate of the maximum size of the list
⮚ waste space
🞂 printList and find: O(n)
🞂 findKth: O(k)
🞂 insert and delete: O(n)
🞂 e.g. insert at position 0 (making a new element)
🞂 requires first pushing the entire array down one spot to make room
🞂 e.g. delete at position 0
🞂 requires shifting all the elements in the list up one
🞂 On average, half of the lists needs to be moved for either
operation
• Array Declaration
• Int arr[10];
• b=10;
• int arr1[b];
• int [b+5];
• 2-D Array
• int arr2[4][5];
Dynamic array declaration
• int size_arr;
• scanf("&d",&size_arr);
• int *arr1 = (int*)malloc(sizeof(int)*size_arr);
• int p11[size];
• for(i = 0; i < size; i++ )
• { scanf("%d",&p11[i])
• }
• Or
• for(i = 0; i < size; i++ )
• { scanf("%d",(p11+i));
• }
Multi-dimensional SPARSE Matrix
• A matrix is a two-dimensional data object made of m
rows and n columns, therefore having m X n values.
When m=n, we call it a square matrix.
• There may be a situation in which a matrix contains
more number of ZERO values than NON-ZERO values.
Such matrix is known as sparse matrix.
• When a sparse matrix is represented with 2-
dimensional array, we waste lot of space to represent
that matrix.
• For example, consider a matrix of size 100 X 100
containing only 10 non-zero elements.
Contd…
• In this matrix, only 10 spaces are filled with non-zero values
and remaining spaces of matrix are filled with zero.
• totally we allocate 100 X 100 X 2 = 20000 bytes of space to
store this integer matrix.
• to access these 10 non-zero elements we have to make
scanning for 10000 times.
• If most of the elements in a matrix have the value 0, then the
matrix is called sparSe matrix.
Example For 3 X 3 Sparse Matrix:
•
| 1 0 0 |
| 0 0 0 |
| 0 4 0 |
Sparse Matrix Representations
• A sparse matrix can be represented by using TWO representations,
those are as follows...
• Triplet Representation
• Linked Representation
TRIPLET REPRESENTATION (ARRAY REPRESENTATION)
• In this representation, only non-zero values are considered along with
their row and column index values.
• The array index [0,0] stores the total number of rows, [0,1] index
stores the total number of columns and [0,1] index has the total
number of non-zero values in the sparse matrix.
• For example, consider a matrix of size 5 X 6 containing 6 number of
non-zero values.
TRIPLET REPRESENTATION
Array Implementation
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
printf("%d ",Arr[i][j]);
}
printf("n");
}
for(i=0;i<m;i++)
{
for(j=0;j<n;j++)
{
if(Arr[i][j]!=0)
{
B1[s1][0]=Arr[i][j];
B1[s1][1]=i;
B1[s1][2]=j;
s1++;} }
}
Linked List Representation
• In linked list representation, a linked list data structure is used to
represent a sparse matrix.
• In linked list, each node has four fields. These four fields are defined
as:
• Row: Index of row, where non-zero element is located
• Column: Index of column, where non-zero element is located
• Value: Value of the non zero element located at index – (row,column)
• Next node: Address of the next node
Linked List Representation
Node Declaration
Data structure and algorithm list structures
Cursor Implementation
• Some programming languages doesn’t support pointers.
• But we need linked list representation to store data.
• Solution:
• Cursor implementation – implementing linked list on an array.
• Main idea is:
• Convert a linked list based implementation to an array based
implementation.
• Instead of pointers, array index could be used to keep track of node.
• Convert the node structures (collection of data and next pointer) to
a global array of structures.
• Need to find a way to perform dynamic memory allocation
performed using malloc and free functions.
Declarations for cursor implementation of
linked lists
Initializing Cursor Space
• Cursor_space[list] =0;
• To check whether cursor_space is empty:
• To check whether p is last in a linked list
Ad

Recommended

DSA UNIT II ARRAY AND LIST - notes
DSA UNIT II ARRAY AND LIST - notes
swathirajstar
 
1.Array and linklst definition
1.Array and linklst definition
balavigneshwari
 
U2.pptx Advanced Data Structures and Algorithms
U2.pptx Advanced Data Structures and Algorithms
snehalkulkarni78
 
Unit 2 dsa LINEAR DATA STRUCTURE
Unit 2 dsa LINEAR DATA STRUCTURE
PUNE VIDYARTHI GRIHA'S COLLEGE OF ENGINEERING, NASHIK
 
Array
Array
Malainine Zaid
 
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
8.DATA STRUCTURES UNIT 1 AND 2 CS3301PPT.pptx
venigkrish89
 
DSA Unit II array.pptx
DSA Unit II array.pptx
sayalishivarkar1
 
TMK_DSA_Unit 2 part1(array and stack).pptx
TMK_DSA_Unit 2 part1(array and stack).pptx
dhruvkareliya1004
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
nsitlokeshjain
 
Arrays
Arrays
DebiPrasadSen
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Malikireddy Bramhananda Reddy
 
unit 2.pptx
unit 2.pptx
researchgrad82
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
Arrays and vectors in Data Structure.ppt
Arrays and vectors in Data Structure.ppt
mazanali7145
 
Array
Array
Vivian Chia En Chiang
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel
 
arrays in data structure.pptx
arrays in data structure.pptx
KasthuriKAssistantPr
 
arrays.pptx
arrays.pptx
HarmanShergill5
 
unit-2-dsa.pptx
unit-2-dsa.pptx
sayalishivarkar1
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
Aakash deep Singhal
 
EC2311 – Data Structures and C Programming
EC2311 – Data Structures and C Programming
Padma Priya
 
unit 1_Linked list.pptx
unit 1_Linked list.pptx
ssuser7922b8
 
A singly linked list is a linear data structure
A singly linked list is a linear data structure
sangeethavinoth
 
01245xsfwegrgdvdvsdfgvsdgsdfgsfsdgsdgsdgdg
01245xsfwegrgdvdvsdfgvsdgsdfgsfsdgsdgsdgdg
wrushabhsirsat
 
Arrays
Arrays
Komal Singh
 
lecture 02.2.ppt
lecture 02.2.ppt
NathanielAdika
 
2.DS Array
2.DS Array
Chandan Singh
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
AntareepMajumder
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
Quiz on EV , made fun and progressive !!!
Quiz on EV , made fun and progressive !!!
JaishreeAsokanEEE
 

More Related Content

Similar to Data structure and algorithm list structures (20)

Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
nsitlokeshjain
 
Arrays
Arrays
DebiPrasadSen
 
M v bramhananda reddy dsa complete notes
M v bramhananda reddy dsa complete notes
Malikireddy Bramhananda Reddy
 
unit 2.pptx
unit 2.pptx
researchgrad82
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
Arrays and vectors in Data Structure.ppt
Arrays and vectors in Data Structure.ppt
mazanali7145
 
Array
Array
Vivian Chia En Chiang
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel
 
arrays in data structure.pptx
arrays in data structure.pptx
KasthuriKAssistantPr
 
arrays.pptx
arrays.pptx
HarmanShergill5
 
unit-2-dsa.pptx
unit-2-dsa.pptx
sayalishivarkar1
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
Aakash deep Singhal
 
EC2311 – Data Structures and C Programming
EC2311 – Data Structures and C Programming
Padma Priya
 
unit 1_Linked list.pptx
unit 1_Linked list.pptx
ssuser7922b8
 
A singly linked list is a linear data structure
A singly linked list is a linear data structure
sangeethavinoth
 
01245xsfwegrgdvdvsdfgvsdgsdfgsfsdgsdgsdgdg
01245xsfwegrgdvdvsdfgvsdgsdfgsfsdgsdgsdgdg
wrushabhsirsat
 
Arrays
Arrays
Komal Singh
 
lecture 02.2.ppt
lecture 02.2.ppt
NathanielAdika
 
2.DS Array
2.DS Array
Chandan Singh
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
AntareepMajumder
 
Basic of array and data structure, data structure basics, array, address calc...
Basic of array and data structure, data structure basics, array, address calc...
nsitlokeshjain
 
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Datastructures and algorithms prepared by M.V.Brehmanada Reddy
Malikireddy Bramhananda Reddy
 
Arrays and vectors in Data Structure.ppt
Arrays and vectors in Data Structure.ppt
mazanali7145
 
02 Arrays And Memory Mapping
02 Arrays And Memory Mapping
Qundeel
 
Lecture 3 data structures and algorithms
Lecture 3 data structures and algorithms
Aakash deep Singhal
 
EC2311 – Data Structures and C Programming
EC2311 – Data Structures and C Programming
Padma Priya
 
unit 1_Linked list.pptx
unit 1_Linked list.pptx
ssuser7922b8
 
A singly linked list is a linear data structure
A singly linked list is a linear data structure
sangeethavinoth
 
01245xsfwegrgdvdvsdfgvsdgsdfgsfsdgsdgsdgdg
01245xsfwegrgdvdvsdfgvsdgsdfgsfsdgsdgsdgdg
wrushabhsirsat
 
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
FALLSEM2022-23_BCSE202L_TH_VL2022230103292_Reference_Material_II_08-08-2022_D...
AntareepMajumder
 

Recently uploaded (20)

Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
Quiz on EV , made fun and progressive !!!
Quiz on EV , made fun and progressive !!!
JaishreeAsokanEEE
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
ravicivil
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Engineering Mechanics Introduction and its Application
Engineering Mechanics Introduction and its Application
Sakthivel M
 
NALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,Pitch
arpitprachi123
 
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
CenterEnamel
 
IntroSlides-June-GDG-Cloud-Munich community [email protected]
IntroSlides-June-GDG-Cloud-Munich community [email protected]
Luiz Carneiro
 
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
ieijjournal
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
Week 6- PC HARDWARE AND MAINTENANCE-THEORY.pptx
dayananda54
 
Quiz on EV , made fun and progressive !!!
Quiz on EV , made fun and progressive !!!
JaishreeAsokanEEE
 
special_edition_using_visual_foxpro_6.pdf
special_edition_using_visual_foxpro_6.pdf
Shabista Imam
 
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Tally.ERP 9 at a Glance.book - Tally Solutions .pdf
Shabista Imam
 
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
COMPOSITE COLUMN IN STEEL CONCRETE COMPOSITES.ppt
ravicivil
 
Complete guidance book of Asp.Net Web API
Complete guidance book of Asp.Net Web API
Shabista Imam
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
362 Alec Data Center Solutions-Slysium Data Center-AUH-Glands & Lugs, Simplex...
djiceramil
 
Fundamentals of Digital Design_Class_21st May - Copy.pptx
Fundamentals of Digital Design_Class_21st May - Copy.pptx
drdebarshi1993
 
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
Decoding Kotlin - Your Guide to Solving the Mysterious in Kotlin - Devoxx PL ...
João Esperancinha
 
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
Introduction to Natural Language Processing - Stages in NLP Pipeline, Challen...
resming1
 
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
362 Alec Data Center Solutions-Slysium Data Center-AUH-Adaptaflex.pdf
djiceramil
 
Engineering Mechanics Introduction and its Application
Engineering Mechanics Introduction and its Application
Sakthivel M
 
NALCO Green Anode Plant,Compositions of CPC,Pitch
NALCO Green Anode Plant,Compositions of CPC,Pitch
arpitprachi123
 
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
Center Enamel can Provide Aluminum Dome Roofs for diesel tank.docx
CenterEnamel
 
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
Low Power SI Class E Power Amplifier and Rf Switch for Health Care
ieijjournal
 
Structured Programming with C++ :: Kjell Backman
Structured Programming with C++ :: Kjell Backman
Shabista Imam
 
Complete University of Calculus :: 2nd edition
Complete University of Calculus :: 2nd edition
Shabista Imam
 
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
最新版美国圣莫尼卡学院毕业证(SMC毕业证书)原版定制
Taqyea
 
Fundamentals of Digital Design_Class_12th April.pptx
Fundamentals of Digital Design_Class_12th April.pptx
drdebarshi1993
 
Ad

Data structure and algorithm list structures

  • 1. Data Structures and Algorithms UNIT-II-List Structure
  • 2. Syllabus Operations on List ADT – Create, Insert, Search, Delete, Display elements; Implementation of List ADT – Array, Cursor based and Linked Types – Singly, Doubly, Circular; Applications - Sparse Matrix, Polynomial Arithmetic, Joseph Problem
  • 3. Operations on List ADT ADT = properties + operations • An ADT describes a set of objects sharing the same properties and behaviors • The properties of an ADT are its data (representing the internal state of each object • double d; -- bits representing exponent & mantissa are its data or state • The behaviors of an ADT are its operations or functions (operations on each instance) • sqrt(d) / 2; //operators & functions are its behaviors
  • 4. The List ADT  A sequence of zero or more elements A1, A2, A3, … AN  N: length of the list  A1: first element  AN: last element  Ai: position i  If N=0, then empty list  Linearly ordered  Ai precedes Ai+1  Ai follows Ai-1
  • 5. Operations  makeEmpty: create an empty list  find: locate the position of an object in a list  list: 34,12, 52, 16, 12  find(52)  3  insert: insert an object to a list  insert(x,3)  34, 12, 52, x, 16, 12  remove: delete an element from the list  remove(52)  34, 12, x, 16, 12  findKth: retrieve the element at a certain position  printList: print the list
  • 6. Implementation of an ADT • Choose a data structure to represent the ADT • E.g. arrays, records, etc. • Each operation associated with the ADT is implemented by one or more subroutines • Two standard implementations for the list ADT • Array-based • Linked list
  • 7. Array Implementation • Elements are stored in contiguous array positions
  • 8. 1D Array Representation • 1-dimensional array x = [a, b, c, d] • map into contiguous memory locations
  • 9. 2D Arrays • The elements of a 2-dimensional array a declared as: int a[3][4] ; • may be shown as a table a[0][0] a[0][1] a[0][2] a[0][3] a[1][0] a[1][1] a[1][2] a[1][3] a[2][0] a[2][1] a[2][2] a[2][3]
  • 11. Linear List Array Representation • use a one-dimensional array called alphabet[] • List = (a, b, c, d, e) • Store element I of list in alphabet[i]
  • 12. To add an element
  • 13. To remove an element
  • 14. Array Applications • Stores Elements of Same Data Type • Array Used for Maintaining multiple variable names using single name • Array Can be Used for Sorting Elements • Array Can Perform Matrix Operation • Array Can be Used in CPU Scheduling • Array Can be Used in Recursive Function
  • 15. Array Implementation... 🞂 Requires an estimate of the maximum size of the list ⮚ waste space 🞂 printList and find: O(n) 🞂 findKth: O(k) 🞂 insert and delete: O(n) 🞂 e.g. insert at position 0 (making a new element) 🞂 requires first pushing the entire array down one spot to make room 🞂 e.g. delete at position 0 🞂 requires shifting all the elements in the list up one 🞂 On average, half of the lists needs to be moved for either operation
  • 16. • Array Declaration • Int arr[10]; • b=10; • int arr1[b]; • int [b+5]; • 2-D Array • int arr2[4][5];
  • 17. Dynamic array declaration • int size_arr; • scanf("&d",&size_arr); • int *arr1 = (int*)malloc(sizeof(int)*size_arr); • int p11[size]; • for(i = 0; i < size; i++ ) • { scanf("%d",&p11[i]) • } • Or • for(i = 0; i < size; i++ ) • { scanf("%d",(p11+i)); • }
  • 18. Multi-dimensional SPARSE Matrix • A matrix is a two-dimensional data object made of m rows and n columns, therefore having m X n values. When m=n, we call it a square matrix. • There may be a situation in which a matrix contains more number of ZERO values than NON-ZERO values. Such matrix is known as sparse matrix. • When a sparse matrix is represented with 2- dimensional array, we waste lot of space to represent that matrix. • For example, consider a matrix of size 100 X 100 containing only 10 non-zero elements.
  • 19. Contd… • In this matrix, only 10 spaces are filled with non-zero values and remaining spaces of matrix are filled with zero. • totally we allocate 100 X 100 X 2 = 20000 bytes of space to store this integer matrix. • to access these 10 non-zero elements we have to make scanning for 10000 times. • If most of the elements in a matrix have the value 0, then the matrix is called sparSe matrix. Example For 3 X 3 Sparse Matrix: • | 1 0 0 | | 0 0 0 | | 0 4 0 |
  • 20. Sparse Matrix Representations • A sparse matrix can be represented by using TWO representations, those are as follows... • Triplet Representation • Linked Representation
  • 21. TRIPLET REPRESENTATION (ARRAY REPRESENTATION) • In this representation, only non-zero values are considered along with their row and column index values. • The array index [0,0] stores the total number of rows, [0,1] index stores the total number of columns and [0,1] index has the total number of non-zero values in the sparse matrix. • For example, consider a matrix of size 5 X 6 containing 6 number of non-zero values.
  • 24. Linked List Representation • In linked list representation, a linked list data structure is used to represent a sparse matrix. • In linked list, each node has four fields. These four fields are defined as: • Row: Index of row, where non-zero element is located • Column: Index of column, where non-zero element is located • Value: Value of the non zero element located at index – (row,column) • Next node: Address of the next node
  • 28. Cursor Implementation • Some programming languages doesn’t support pointers. • But we need linked list representation to store data. • Solution: • Cursor implementation – implementing linked list on an array. • Main idea is: • Convert a linked list based implementation to an array based implementation. • Instead of pointers, array index could be used to keep track of node. • Convert the node structures (collection of data and next pointer) to a global array of structures. • Need to find a way to perform dynamic memory allocation performed using malloc and free functions.
  • 29. Declarations for cursor implementation of linked lists
  • 30. Initializing Cursor Space • Cursor_space[list] =0; • To check whether cursor_space is empty: • To check whether p is last in a linked list