SlideShare a Scribd company logo
1 of 18
Application of linked list
• Polynomial ADT
• Radix ADT
• Multilist
Polynomial ADT:
We can perform the polynomial
manipulations such as addition, subtraction and
differentiation etc,.
Declaration:
struct poly
{
int coeff;
int power;
struct poly *next;
}*list1,*list2,*list3;
Creation of the polynomial:
poly create(poly *head1,poly *newnode1)
{
poly *ptr;
if(head1==NULL)
{
head1=newnode1;
}
else
{
ptr=head1;
while(ptr->next!=NULL)
ptr=ptr->next;
ptr->next=newnode1;
}
return(head1);
}
Linked list based polynomial addition
void add()
{
poly *ptr1,*ptr2, *newnode;
ptr1=list1;
ptr2=list2;
while(ptr1!=NULL && ptr2!=NULL)
{
newnode=malloc(sizeof(struct poly));
if(ptr1-> power == ptr2-> power)
{
newnode ->coeff=ptr1->coeff+ ptr2->coeff;
newnode-> power = ptr1-> power;
newnode-> next =NULL;
list 3= create(list3, newnode)
ptr1 = ptr1-> next;
ptr2 = ptr2 -> next;
}
else
{
if(ptr1-> power > ptr2--> power)
{
newnode ->coeff=ptr1->coeff;
newnode-> power = ptr1-> power;
newnode-> next =NULL;
list 3= create(list3, newnode)
ptr1 = ptr1-> next;
}
else
{
newnode ->coeff=ptr2->coeff;
newnode-> power = ptr2-> power;
newnode-> next =NULL;
list 3= create(list3, newnode)
ptr2 = ptr2-> next;
}
}
}
Example
Input: 1st number =
5x^2 + 4x^1 + 2x^0
2nd number =
5x^1 + 5x^0
Output: 5x^2 + 9x^1 + 7x^0
Input: 1st number = 5x^3 +
4x^2 + 2x^0
2nd number = 5x^1 + 5x^0
Output: 5x^3 + 4x^2 + 5x^1
+ 7x^0
Linked list based polynomial
Subtraction
void sub()
{
poly *ptr1,*ptr2, *newnode;
ptr1=list1;
ptr2=list2;
while(ptr1!=NULL && ptr2!=NULL)
{
newnode=malloc(sizeof(struct poly));
if(ptr1-> power == ptr2-> power)
{
newnode ->coeff=ptr1->coeff - ptr2->coeff;
newnode-> power = ptr1-> power;
newnode-> next =NULL;
list 3= create(list3, newnode)
ptr1 = ptr1-> next;
ptr2 = ptr2 -> next;
}
else
{
if(ptr1-> power > ptr2-> power)
{
newnode ->coeff=ptr1->coeff;
newnode-> power = ptr1-> power;
newnode-> next =NULL;
list 3= create(list3, newnode)
ptr1 = ptr1-> next;
}
else
{
newnode ->coeff=ptr2->coeff;
newnode-> power = ptr2-> power;
newnode-> next =NULL;
list 3= create(list3, newnode)
ptr2 = ptr2-> next;
}
}
}
Poly * multiply()
{
Node *ptr1, *ptr2,*Newnode;
ptr1 = list1;
ptr2 = list2;
while (ptr1 != NULL)
{
while (ptr2 != NULL)
{
Newnode->coeff = ptr1->coeff * ptr2->coeff;
Newnode->power = ptr1->power + ptr2->power;
list2=create(list3,Newnode);
ptr2 = ptr2->next;
}
ptr2 = list2;
ptr1 = ptr1->next;
}
}
Radix Sort:
• Radix sort is one of the sorting algorithms used
to sort a list of integer numbers in order. In
radix sort algorithm, a list of integer numbers
will be sorted based on the digits of individual
numbers.
• Radix sort algorithm requires the number of
passes which are equal to the number of digits
present in the largest number among the list of
numbers.
• For example, if the largest number is a 3 digit
number then that list is sorted with 3 passes.
Multi-Linked Lists
• A multilinked list is a more general linked list
with multiple links from nodes.
• In a general multi-linked list each node can
have any number of pointers to other nodes,
• Multi-lists are essentially the technique of
embedding multiple lists into a single data
structure.
• A multi-list has more than one next pointer,
like a doubly linked list, but the pointers
create separate lists

More Related Content

What's hot (20)

Statistics - ArgMax Equation
Statistics - ArgMax EquationStatistics - ArgMax Equation
Statistics - ArgMax Equation
 
Numpy
NumpyNumpy
Numpy
 
Ds0601 stack
Ds0601 stackDs0601 stack
Ds0601 stack
 
Hashing PPT
Hashing PPTHashing PPT
Hashing PPT
 
Numpy
NumpyNumpy
Numpy
 
Hashing
HashingHashing
Hashing
 
Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure Binary Heap Tree, Data Structure
Binary Heap Tree, Data Structure
 
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)Hashing notes data structures (HASHING AND HASH FUNCTIONS)
Hashing notes data structures (HASHING AND HASH FUNCTIONS)
 
Data Structure and Algorithms Hashing
Data Structure and Algorithms HashingData Structure and Algorithms Hashing
Data Structure and Algorithms Hashing
 
Smalltalk
SmalltalkSmalltalk
Smalltalk
 
Hash table
Hash tableHash table
Hash table
 
Hashing
HashingHashing
Hashing
 
Ds 8
Ds 8Ds 8
Ds 8
 
Heapsort quick sort
Heapsort quick sortHeapsort quick sort
Heapsort quick sort
 
Hashing
HashingHashing
Hashing
 
Heapsort using Heap
Heapsort using HeapHeapsort using Heap
Heapsort using Heap
 
Heaps
HeapsHeaps
Heaps
 
Array & string
Array & stringArray & string
Array & string
 
Lec16
Lec16Lec16
Lec16
 
4.4 external hashing
4.4 external hashing4.4 external hashing
4.4 external hashing
 

Similar to CS8391-Data Structures Unit 1

linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptxchin463670
 
Change the driver file (the main .cpp) so that it asks the user to e.pdf
Change the driver file (the main .cpp) so that it asks the user to e.pdfChange the driver file (the main .cpp) so that it asks the user to e.pdf
Change the driver file (the main .cpp) so that it asks the user to e.pdffatoryoutlets
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdffeelinggift
 
COMP2710: Software Construction - Linked list exercises
COMP2710: Software Construction - Linked list exercisesCOMP2710: Software Construction - Linked list exercises
COMP2710: Software Construction - Linked list exercisesXiao Qin
 
Lecture 4 data structures and algorithms
Lecture 4 data structures and algorithmsLecture 4 data structures and algorithms
Lecture 4 data structures and algorithmsAakash deep Singhal
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfpoblettesedanoree498
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdffantoosh1
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklistritu1806
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfsales98
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfEricvtJFraserr
 

Similar to CS8391-Data Structures Unit 1 (20)

linked list.pptx
linked list.pptxlinked list.pptx
linked list.pptx
 
Ll.pptx
Ll.pptxLl.pptx
Ll.pptx
 
Change the driver file (the main .cpp) so that it asks the user to e.pdf
Change the driver file (the main .cpp) so that it asks the user to e.pdfChange the driver file (the main .cpp) so that it asks the user to e.pdf
Change the driver file (the main .cpp) so that it asks the user to e.pdf
 
Linked List.pptx
Linked List.pptxLinked List.pptx
Linked List.pptx
 
3.linked list
3.linked list3.linked list
3.linked list
 
How do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdfHow do you stop infinite loop Because I believe that it is making a.pdf
How do you stop infinite loop Because I believe that it is making a.pdf
 
Linked lists a
Linked lists aLinked lists a
Linked lists a
 
COMP2710: Software Construction - Linked list exercises
COMP2710: Software Construction - Linked list exercisesCOMP2710: Software Construction - Linked list exercises
COMP2710: Software Construction - Linked list exercises
 
Lecture 4 data structures and algorithms
Lecture 4 data structures and algorithmsLecture 4 data structures and algorithms
Lecture 4 data structures and algorithms
 
dynamicList.ppt
dynamicList.pptdynamicList.ppt
dynamicList.ppt
 
Unit - 2.pdf
Unit - 2.pdfUnit - 2.pdf
Unit - 2.pdf
 
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdfC++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
C++ Doubly-Linked ListsThe goal of the exercise is to implement a.pdf
 
Linked list
Linked listLinked list
Linked list
 
DSA(1).pptx
DSA(1).pptxDSA(1).pptx
DSA(1).pptx
 
In C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdfIn C++ I need help with this method that Im trying to write fillLi.pdf
In C++ I need help with this method that Im trying to write fillLi.pdf
 
Unit7 C
Unit7 CUnit7 C
Unit7 C
 
Team 10
Team 10Team 10
Team 10
 
Doublylinklist
DoublylinklistDoublylinklist
Doublylinklist
 
Consider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdfConsider a double-linked linked list implementation with the followin.pdf
Consider a double-linked linked list implementation with the followin.pdf
 
This assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdfThis assignment and the next (#5) involve design and development of a.pdf
This assignment and the next (#5) involve design and development of a.pdf
 

More from SIMONTHOMAS S

Cs8092 computer graphics and multimedia unit 5
Cs8092 computer graphics and multimedia unit 5Cs8092 computer graphics and multimedia unit 5
Cs8092 computer graphics and multimedia unit 5SIMONTHOMAS S
 
Cs8092 computer graphics and multimedia unit 4
Cs8092 computer graphics and multimedia unit 4Cs8092 computer graphics and multimedia unit 4
Cs8092 computer graphics and multimedia unit 4SIMONTHOMAS S
 
Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3SIMONTHOMAS S
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2SIMONTHOMAS S
 
Cs8092 computer graphics and multimedia unit 1
Cs8092 computer graphics and multimedia unit 1Cs8092 computer graphics and multimedia unit 1
Cs8092 computer graphics and multimedia unit 1SIMONTHOMAS S
 
IT6701-Information Management Unit 5
IT6701-Information Management Unit 5IT6701-Information Management Unit 5
IT6701-Information Management Unit 5SIMONTHOMAS S
 
IT6701-Information Management Unit 4
IT6701-Information Management Unit 4IT6701-Information Management Unit 4
IT6701-Information Management Unit 4SIMONTHOMAS S
 
IT6701-Information Management Unit 3
IT6701-Information Management Unit 3IT6701-Information Management Unit 3
IT6701-Information Management Unit 3SIMONTHOMAS S
 
IT6701-Information Management Unit 2
IT6701-Information Management Unit 2IT6701-Information Management Unit 2
IT6701-Information Management Unit 2SIMONTHOMAS S
 
IT6701-Information Management Unit 1
IT6701-Information Management Unit 1IT6701-Information Management Unit 1
IT6701-Information Management Unit 1SIMONTHOMAS S
 
CS8391-Data Structures Unit 5
CS8391-Data Structures Unit 5CS8391-Data Structures Unit 5
CS8391-Data Structures Unit 5SIMONTHOMAS S
 
CS8391-Data Structures Unit 4
CS8391-Data Structures Unit 4CS8391-Data Structures Unit 4
CS8391-Data Structures Unit 4SIMONTHOMAS S
 
CS8391-Data Structures Unit 3
CS8391-Data Structures Unit 3CS8391-Data Structures Unit 3
CS8391-Data Structures Unit 3SIMONTHOMAS S
 
CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2SIMONTHOMAS S
 

More from SIMONTHOMAS S (20)

Cs8092 computer graphics and multimedia unit 5
Cs8092 computer graphics and multimedia unit 5Cs8092 computer graphics and multimedia unit 5
Cs8092 computer graphics and multimedia unit 5
 
Cs8092 computer graphics and multimedia unit 4
Cs8092 computer graphics and multimedia unit 4Cs8092 computer graphics and multimedia unit 4
Cs8092 computer graphics and multimedia unit 4
 
Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3Cs8092 computer graphics and multimedia unit 3
Cs8092 computer graphics and multimedia unit 3
 
Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2Cs8092 computer graphics and multimedia unit 2
Cs8092 computer graphics and multimedia unit 2
 
Cs8092 computer graphics and multimedia unit 1
Cs8092 computer graphics and multimedia unit 1Cs8092 computer graphics and multimedia unit 1
Cs8092 computer graphics and multimedia unit 1
 
Mg6088 spm unit-5
Mg6088 spm unit-5Mg6088 spm unit-5
Mg6088 spm unit-5
 
Mg6088 spm unit-4
Mg6088 spm unit-4Mg6088 spm unit-4
Mg6088 spm unit-4
 
Mg6088 spm unit-3
Mg6088 spm unit-3Mg6088 spm unit-3
Mg6088 spm unit-3
 
Mg6088 spm unit-2
Mg6088 spm unit-2Mg6088 spm unit-2
Mg6088 spm unit-2
 
Mg6088 spm unit-1
Mg6088 spm unit-1Mg6088 spm unit-1
Mg6088 spm unit-1
 
IT6701-Information Management Unit 5
IT6701-Information Management Unit 5IT6701-Information Management Unit 5
IT6701-Information Management Unit 5
 
IT6701-Information Management Unit 4
IT6701-Information Management Unit 4IT6701-Information Management Unit 4
IT6701-Information Management Unit 4
 
IT6701-Information Management Unit 3
IT6701-Information Management Unit 3IT6701-Information Management Unit 3
IT6701-Information Management Unit 3
 
IT6701-Information Management Unit 2
IT6701-Information Management Unit 2IT6701-Information Management Unit 2
IT6701-Information Management Unit 2
 
IT6701-Information Management Unit 1
IT6701-Information Management Unit 1IT6701-Information Management Unit 1
IT6701-Information Management Unit 1
 
CS8391-Data Structures Unit 5
CS8391-Data Structures Unit 5CS8391-Data Structures Unit 5
CS8391-Data Structures Unit 5
 
CS8391-Data Structures Unit 4
CS8391-Data Structures Unit 4CS8391-Data Structures Unit 4
CS8391-Data Structures Unit 4
 
CS8391-Data Structures Unit 3
CS8391-Data Structures Unit 3CS8391-Data Structures Unit 3
CS8391-Data Structures Unit 3
 
CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2CS8391-Data Structures Unit 2
CS8391-Data Structures Unit 2
 
SPC Unit 5
SPC Unit 5SPC Unit 5
SPC Unit 5
 

Recently uploaded

VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130Suhani Kapoor
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learningmisbanausheenparvam
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx959SahilShah
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSCAESB
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxvipinkmenon1
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionDr.Costas Sachpazis
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝soniya singh
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacingjaychoudhary37
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...Soham Mondal
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile servicerehmti665
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVRajaP95
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxJoão Esperancinha
 

Recently uploaded (20)

young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Serviceyoung call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
young call girls in Rajiv Chowk🔝 9953056974 🔝 Delhi escort Service
 
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
VIP Call Girls Service Hitech City Hyderabad Call +91-8250192130
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service NashikCollege Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
College Call Girls Nashik Nehal 7001305949 Independent Escort Service Nashik
 
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
🔝9953056974🔝!!-YOUNG call girls in Rajendra Nagar Escort rvice Shot 2000 nigh...
 
chaitra-1.pptx fake news detection using machine learning
chaitra-1.pptx  fake news detection using machine learningchaitra-1.pptx  fake news detection using machine learning
chaitra-1.pptx fake news detection using machine learning
 
Application of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptxApplication of Residue Theorem to evaluate real integrations.pptx
Application of Residue Theorem to evaluate real integrations.pptx
 
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
VICTOR MAESTRE RAMIREZ - Planetary Defender on NASA's Double Asteroid Redirec...
 
GDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentationGDSC ASEB Gen AI study jams presentation
GDSC ASEB Gen AI study jams presentation
 
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
★ CALL US 9953330565 ( HOT Young Call Girls In Badarpur delhi NCR
 
Introduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptxIntroduction to Microprocesso programming and interfacing.pptx
Introduction to Microprocesso programming and interfacing.pptx
 
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
9953056974 Call Girls In South Ex, Escorts (Delhi) NCR.pdf
 
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective IntroductionSachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
Sachpazis Costas: Geotechnical Engineering: A student's Perspective Introduction
 
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
Model Call Girl in Narela Delhi reach out to us at 🔝8264348440🔝
 
microprocessor 8085 and its interfacing
microprocessor 8085  and its interfacingmicroprocessor 8085  and its interfacing
microprocessor 8085 and its interfacing
 
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
OSVC_Meta-Data based Simulation Automation to overcome Verification Challenge...
 
Call Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile serviceCall Girls Delhi {Jodhpur} 9711199012 high profile service
Call Girls Delhi {Jodhpur} 9711199012 high profile service
 
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptxExploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
Exploring_Network_Security_with_JA3_by_Rakesh Seal.pptx
 
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IVHARMONY IN THE NATURE AND EXISTENCE - Unit-IV
HARMONY IN THE NATURE AND EXISTENCE - Unit-IV
 
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptxDecoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
Decoding Kotlin - Your guide to solving the mysterious in Kotlin.pptx
 

CS8391-Data Structures Unit 1

  • 1. Application of linked list • Polynomial ADT • Radix ADT • Multilist
  • 2. Polynomial ADT: We can perform the polynomial manipulations such as addition, subtraction and differentiation etc,. Declaration: struct poly { int coeff; int power; struct poly *next; }*list1,*list2,*list3;
  • 3. Creation of the polynomial: poly create(poly *head1,poly *newnode1) { poly *ptr; if(head1==NULL) { head1=newnode1; }
  • 5. Linked list based polynomial addition void add() { poly *ptr1,*ptr2, *newnode; ptr1=list1; ptr2=list2; while(ptr1!=NULL && ptr2!=NULL) { newnode=malloc(sizeof(struct poly));
  • 6. if(ptr1-> power == ptr2-> power) { newnode ->coeff=ptr1->coeff+ ptr2->coeff; newnode-> power = ptr1-> power; newnode-> next =NULL; list 3= create(list3, newnode) ptr1 = ptr1-> next; ptr2 = ptr2 -> next; }
  • 7. else { if(ptr1-> power > ptr2--> power) { newnode ->coeff=ptr1->coeff; newnode-> power = ptr1-> power; newnode-> next =NULL; list 3= create(list3, newnode) ptr1 = ptr1-> next; }
  • 8. else { newnode ->coeff=ptr2->coeff; newnode-> power = ptr2-> power; newnode-> next =NULL; list 3= create(list3, newnode) ptr2 = ptr2-> next; } } }
  • 9. Example Input: 1st number = 5x^2 + 4x^1 + 2x^0 2nd number = 5x^1 + 5x^0 Output: 5x^2 + 9x^1 + 7x^0 Input: 1st number = 5x^3 + 4x^2 + 2x^0 2nd number = 5x^1 + 5x^0 Output: 5x^3 + 4x^2 + 5x^1 + 7x^0
  • 10. Linked list based polynomial Subtraction void sub() { poly *ptr1,*ptr2, *newnode; ptr1=list1; ptr2=list2; while(ptr1!=NULL && ptr2!=NULL) { newnode=malloc(sizeof(struct poly));
  • 11. if(ptr1-> power == ptr2-> power) { newnode ->coeff=ptr1->coeff - ptr2->coeff; newnode-> power = ptr1-> power; newnode-> next =NULL; list 3= create(list3, newnode) ptr1 = ptr1-> next; ptr2 = ptr2 -> next; }
  • 12. else { if(ptr1-> power > ptr2-> power) { newnode ->coeff=ptr1->coeff; newnode-> power = ptr1-> power; newnode-> next =NULL; list 3= create(list3, newnode) ptr1 = ptr1-> next; }
  • 13. else { newnode ->coeff=ptr2->coeff; newnode-> power = ptr2-> power; newnode-> next =NULL; list 3= create(list3, newnode) ptr2 = ptr2-> next; } } }
  • 14. Poly * multiply() { Node *ptr1, *ptr2,*Newnode; ptr1 = list1; ptr2 = list2; while (ptr1 != NULL) { while (ptr2 != NULL) { Newnode->coeff = ptr1->coeff * ptr2->coeff;
  • 15. Newnode->power = ptr1->power + ptr2->power; list2=create(list3,Newnode); ptr2 = ptr2->next; } ptr2 = list2; ptr1 = ptr1->next; } }
  • 16. Radix Sort: • Radix sort is one of the sorting algorithms used to sort a list of integer numbers in order. In radix sort algorithm, a list of integer numbers will be sorted based on the digits of individual numbers. • Radix sort algorithm requires the number of passes which are equal to the number of digits present in the largest number among the list of numbers. • For example, if the largest number is a 3 digit number then that list is sorted with 3 passes.
  • 17.
  • 18. Multi-Linked Lists • A multilinked list is a more general linked list with multiple links from nodes. • In a general multi-linked list each node can have any number of pointers to other nodes, • Multi-lists are essentially the technique of embedding multiple lists into a single data structure. • A multi-list has more than one next pointer, like a doubly linked list, but the pointers create separate lists