SlideShare a Scribd company logo
CS1301- Data structures Using
Python
Unit 1- Linear Data structures
POLYNOMIAL MANIPULATION
Introduction
• Polynomials, which are an important concept
throughout mathematics and science, are arithmetic
expressions specified in terms of variables and
constants.
• A polynomial in one variable can be expressed in
expanded form as
where each aixi component is called a term.
• Polynomials can be characterized by degree
(i.e., all second-degree polynomials).
• We design and implement an abstract data type
to represent
• Polynomials in one variable expressed in
expanded form.
Polynomial Operations
• Addition • Multiplication
Polynomial Operations…
• Evaluation:- Polynomials can be evaluated by
assigning a value to the variable, commonly called
the unknown.
• If we assign value 3 to the variable x in the equation
Polynomial ADT
• Definition: A polynomial is a mathematical
expression of a variable constructed of one or more
terms. Each term is of the form aixi where ai is a
scalar coefficient and xi is the unknown variable of
degree i.
Implementation
• We must determine how best to represent the
individual terms and how to store and manage
the collection of terms.
• The linked list has the advantage of requiring
fewer shifts and no underlying array
management as is required with the Python
list. This is especially important when working
with dynamic polynomials.
Linked List Structure
• To implement our Polynomial ADT using a singly
linked list.
• A polynomial is constructed as the sum of one or
more non-zero terms, we can simply store an
individual term in each node of the list as defined
by the PolyTermNode class.
• The polynomial operations becomes clear with an
ordered list would be better since many of those
operations are based on the degree of the terms.
• A sample linked list structure for the
polynomial 5x2 + 3x = 10
• we need to decide whether our implementation can
benefit from the use of a tail pointer or if a head
pointer alone will suffice.
• The implementation of some of our polynomial
operations can be improved if we append nodes
directly to the end of the linked list.
• Thus, we will use and manage a tail pointer in our
implementation of the Polynomial ADT.
• The Polynomial ADT calls for two constructors,
one for creating an empty polynomial and the
other that can be used to create a polynomial
initialized with a single term supplied as an
argument.
• In Python, we can provide multiple
constructors with the use of default values.
• The degree() method is simple to implement
as it returns either the degree of the largest
term that is stored in the first node or -1 if the
polynomial is not defined.
• The get operation, which we implement using the
subscript operator, returns the coefficient corresponding
to a specific term of the polynomial identified by degree.
• A linear search of the linked list is required to find the
corresponding term.
• A polynomial is evaluated by supplying a specific value
for the variable used to represent each term and then
summing the terms.
• The evaluate() method is easily implemented as a list
traversal in which a sum is accumulated, term by term.
• The result is a O(n) time operation, where n is the degree
of the polynomial.
Appending Terms
• A tail reference in our linked list
implementation for use by several of the
polynomial arithmetic operations in order to
perform fast append operations.
• The appendTerm() helper method in lines
accepts the degree and coefficient of a
polynomial term, creates a new node to store
the term, and appends the node to the end of
the list.
Polynomial Addition
• The new polynomial is created
by iterating over the two
original polynomials, term by
term, from the largest degree
among the two polynomials
down to degree 0.
• The element access method is
used to extract the coefficients
of corresponding terms from
each polynomial, which are
then added, resulting in a term
for the new polynomial.
• Since we iterate over the
polynomials in decreasing
degree order, we can simply
append the new term to the
end of the linked list storing the
new polynomial.

More Related Content

What's hot

Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
Julie Iskander
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
topu93
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
Devashish Kumar
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
Madhu Bala
 
single linked list
single linked listsingle linked list
single linked list
Sathasivam Rangasamy
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
nitamhaske
 
Array ppt
Array pptArray ppt
Array ppt
Kaushal Mehta
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
International Islamic University
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
shameen khan
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
Awais Alam
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
karthikeyanC40
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
Poojith Chowdhary
 
Arrays
ArraysArrays
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
Gokul Hari
 
Python list
Python listPython list
Python list
Mohammed Sikander
 
Strings
StringsStrings
Strings
Nilesh Dalvi
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
Hridoy Bepari
 
Pointer in c
Pointer in cPointer in c
Pointer in c
lavanya marichamy
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
Sharad Dubey
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
Adam Mukharil Bachtiar
 

What's hot (20)

Data structures and algorithms
Data structures and algorithmsData structures and algorithms
Data structures and algorithms
 
Presentation on array
Presentation on array Presentation on array
Presentation on array
 
Data Structures in Python
Data Structures in PythonData Structures in Python
Data Structures in Python
 
Data structure - Graph
Data structure - GraphData structure - Graph
Data structure - Graph
 
single linked list
single linked listsingle linked list
single linked list
 
List,tuple,dictionary
List,tuple,dictionaryList,tuple,dictionary
List,tuple,dictionary
 
Array ppt
Array pptArray ppt
Array ppt
 
Linear search-and-binary-search
Linear search-and-binary-searchLinear search-and-binary-search
Linear search-and-binary-search
 
linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Arrays In C++
Arrays In C++Arrays In C++
Arrays In C++
 
Abstract Data Types
Abstract Data TypesAbstract Data Types
Abstract Data Types
 
Abstract data types
Abstract data typesAbstract data types
Abstract data types
 
Arrays
ArraysArrays
Arrays
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Python list
Python listPython list
Python list
 
Strings
StringsStrings
Strings
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
Pointer in c
Pointer in cPointer in c
Pointer in c
 
Array Of Pointers
Array Of PointersArray Of Pointers
Array Of Pointers
 
Data Structure (Queue)
Data Structure (Queue)Data Structure (Queue)
Data Structure (Queue)
 

Similar to Unit 1 polynomial manipulation

in computer data structures and algorithms
in computer data structures and algorithmsin computer data structures and algorithms
in computer data structures and algorithms
FIONACHATOLA
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
TKSanthoshRao
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
rohithprabhas1
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
Koteswari Kasireddy
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
Koteswari Kasireddy
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
hardii0991
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
hammad463061
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
Tribhuvan University
 
Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
aiclub_slides
 
Data structure
Data structureData structure
Data structure
Muhammad Farhan
 
Unit -I Toc.pptx
Unit -I Toc.pptxUnit -I Toc.pptx
Unit -I Toc.pptx
viswanath kani
 
Complexity
ComplexityComplexity
Complexity
Malainine Zaid
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
Ayshwarya Baburam
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
Jabs6
 
Reference Scope Identification of Citances Using Convolutional Neural Network
Reference Scope Identification of Citances Using Convolutional Neural NetworkReference Scope Identification of Citances Using Convolutional Neural Network
Reference Scope Identification of Citances Using Convolutional Neural Network
Saurav Jha
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptx
chandankumar364348
 
DSA
DSADSA
DSA
rrupa2
 
Theory of algorithms final
Theory of algorithms final Theory of algorithms final
Theory of algorithms final
Dgech
 
Module 3,4.pptx
Module 3,4.pptxModule 3,4.pptx
Module 3,4.pptx
SandeepR95
 
Sort Characters in a Python String Alphabetically
Sort Characters in a Python String AlphabeticallySort Characters in a Python String Alphabetically
Sort Characters in a Python String Alphabetically
Kal Bartal
 

Similar to Unit 1 polynomial manipulation (20)

in computer data structures and algorithms
in computer data structures and algorithmsin computer data structures and algorithms
in computer data structures and algorithms
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Python For Data Science.pptx
Python For Data Science.pptxPython For Data Science.pptx
Python For Data Science.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Algorithm.pptx
Algorithm.pptxAlgorithm.pptx
Algorithm.pptx
 
Engineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptxEngineering CS 5th Sem Python Module -2.pptx
Engineering CS 5th Sem Python Module -2.pptx
 
Discrete structure ch 3 short question's
Discrete structure ch 3 short question'sDiscrete structure ch 3 short question's
Discrete structure ch 3 short question's
 
Unit ii algorithm
Unit   ii algorithmUnit   ii algorithm
Unit ii algorithm
 
Pa1 session 2
Pa1 session 2 Pa1 session 2
Pa1 session 2
 
Data structure
Data structureData structure
Data structure
 
Unit -I Toc.pptx
Unit -I Toc.pptxUnit -I Toc.pptx
Unit -I Toc.pptx
 
Complexity
ComplexityComplexity
Complexity
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Data Structures in C
Data Structures in CData Structures in C
Data Structures in C
 
Reference Scope Identification of Citances Using Convolutional Neural Network
Reference Scope Identification of Citances Using Convolutional Neural NetworkReference Scope Identification of Citances Using Convolutional Neural Network
Reference Scope Identification of Citances Using Convolutional Neural Network
 
session-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptxsession-1_Design_Analysis_Algorithm.pptx
session-1_Design_Analysis_Algorithm.pptx
 
DSA
DSADSA
DSA
 
Theory of algorithms final
Theory of algorithms final Theory of algorithms final
Theory of algorithms final
 
Module 3,4.pptx
Module 3,4.pptxModule 3,4.pptx
Module 3,4.pptx
 
Sort Characters in a Python String Alphabetically
Sort Characters in a Python String AlphabeticallySort Characters in a Python String Alphabetically
Sort Characters in a Python String Alphabetically
 

More from LavanyaJ28

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabus
LavanyaJ28
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
LavanyaJ28
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
LavanyaJ28
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sorting
LavanyaJ28
 
Hashing
HashingHashing
Hashing
LavanyaJ28
 
Graphs
GraphsGraphs
Graphs
LavanyaJ28
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
LavanyaJ28
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & Trees
LavanyaJ28
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
LavanyaJ28
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
LavanyaJ28
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
LavanyaJ28
 
Stack and queue
Stack and queueStack and queue
Stack and queue
LavanyaJ28
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
LavanyaJ28
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DS
LavanyaJ28
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
LavanyaJ28
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
LavanyaJ28
 

More from LavanyaJ28 (16)

Cs1301 syllabus
Cs1301  syllabusCs1301  syllabus
Cs1301 syllabus
 
Ds important questions
Ds important questionsDs important questions
Ds important questions
 
2 marks- DS using python
2 marks- DS using python2 marks- DS using python
2 marks- DS using python
 
Searching,sorting
Searching,sortingSearching,sorting
Searching,sorting
 
Hashing
HashingHashing
Hashing
 
Graphs
GraphsGraphs
Graphs
 
Unit 3 trees
Unit 3   treesUnit 3   trees
Unit 3 trees
 
Heap types & Trees
Heap types & TreesHeap types & Trees
Heap types & Trees
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Unit ii linear data structures
Unit ii linear data structures Unit ii linear data structures
Unit ii linear data structures
 
Unit 2 application of stack
Unit 2  application of stack Unit 2  application of stack
Unit 2 application of stack
 
Stack and queue
Stack and queueStack and queue
Stack and queue
 
Unit 1 linked list
Unit 1 linked listUnit 1 linked list
Unit 1 linked list
 
Unit 1 Basic concepts to DS
Unit 1 Basic concepts to DSUnit 1 Basic concepts to DS
Unit 1 Basic concepts to DS
 
Unit 1 array based implementation
Unit 1  array based implementationUnit 1  array based implementation
Unit 1 array based implementation
 
Unit 1 abstract data types
Unit 1 abstract data typesUnit 1 abstract data types
Unit 1 abstract data types
 

Recently uploaded

International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
gerogepatton
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
Victor Morales
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
zubairahmad848137
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
camseq
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
IJNSA Journal
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
171ticu
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
KrishnaveniKrishnara1
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
Yasser Mahgoub
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Sinan KOZAK
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
rpskprasana
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
KrishnaveniKrishnara1
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
Las Vegas Warehouse
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
Madan Karki
 

Recently uploaded (20)

International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...International Conference on NLP, Artificial Intelligence, Machine Learning an...
International Conference on NLP, Artificial Intelligence, Machine Learning an...
 
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressionsKuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
KuberTENes Birthday Bash Guadalajara - K8sGPT first impressions
 
Casting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdfCasting-Defect-inSlab continuous casting.pdf
Casting-Defect-inSlab continuous casting.pdf
 
Modelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdfModelagem de um CSTR com reação endotermica.pdf
Modelagem de um CSTR com reação endotermica.pdf
 
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMSA SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
A SYSTEMATIC RISK ASSESSMENT APPROACH FOR SECURING THE SMART IRRIGATION SYSTEMS
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样学校原版美国波士顿大学毕业证学历学位证书原版一模一样
学校原版美国波士顿大学毕业证学历学位证书原版一模一样
 
22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt22CYT12-Unit-V-E Waste and its Management.ppt
22CYT12-Unit-V-E Waste and its Management.ppt
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
2008 BUILDING CONSTRUCTION Illustrated - Ching Chapter 02 The Building.pdf
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
Optimizing Gradle Builds - Gradle DPE Tour Berlin 2024
 
CSM Cloud Service Management Presentarion
CSM Cloud Service Management PresentarionCSM Cloud Service Management Presentarion
CSM Cloud Service Management Presentarion
 
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.pptUnit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
Unit-III-ELECTROCHEMICAL STORAGE DEVICES.ppt
 
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have oneISPM 15 Heat Treated Wood Stamps and why your shipping must have one
ISPM 15 Heat Treated Wood Stamps and why your shipping must have one
 
spirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptxspirit beverages ppt without graphics.pptx
spirit beverages ppt without graphics.pptx
 

Unit 1 polynomial manipulation

  • 1. CS1301- Data structures Using Python Unit 1- Linear Data structures
  • 3. Introduction • Polynomials, which are an important concept throughout mathematics and science, are arithmetic expressions specified in terms of variables and constants. • A polynomial in one variable can be expressed in expanded form as where each aixi component is called a term.
  • 4. • Polynomials can be characterized by degree (i.e., all second-degree polynomials). • We design and implement an abstract data type to represent • Polynomials in one variable expressed in expanded form.
  • 6. Polynomial Operations… • Evaluation:- Polynomials can be evaluated by assigning a value to the variable, commonly called the unknown. • If we assign value 3 to the variable x in the equation
  • 7. Polynomial ADT • Definition: A polynomial is a mathematical expression of a variable constructed of one or more terms. Each term is of the form aixi where ai is a scalar coefficient and xi is the unknown variable of degree i.
  • 8.
  • 9. Implementation • We must determine how best to represent the individual terms and how to store and manage the collection of terms. • The linked list has the advantage of requiring fewer shifts and no underlying array management as is required with the Python list. This is especially important when working with dynamic polynomials.
  • 10. Linked List Structure • To implement our Polynomial ADT using a singly linked list. • A polynomial is constructed as the sum of one or more non-zero terms, we can simply store an individual term in each node of the list as defined by the PolyTermNode class. • The polynomial operations becomes clear with an ordered list would be better since many of those operations are based on the degree of the terms.
  • 11. • A sample linked list structure for the polynomial 5x2 + 3x = 10
  • 12. • we need to decide whether our implementation can benefit from the use of a tail pointer or if a head pointer alone will suffice. • The implementation of some of our polynomial operations can be improved if we append nodes directly to the end of the linked list. • Thus, we will use and manage a tail pointer in our implementation of the Polynomial ADT.
  • 13.
  • 14.
  • 15. • The Polynomial ADT calls for two constructors, one for creating an empty polynomial and the other that can be used to create a polynomial initialized with a single term supplied as an argument. • In Python, we can provide multiple constructors with the use of default values. • The degree() method is simple to implement as it returns either the degree of the largest term that is stored in the first node or -1 if the polynomial is not defined.
  • 16. • The get operation, which we implement using the subscript operator, returns the coefficient corresponding to a specific term of the polynomial identified by degree. • A linear search of the linked list is required to find the corresponding term. • A polynomial is evaluated by supplying a specific value for the variable used to represent each term and then summing the terms. • The evaluate() method is easily implemented as a list traversal in which a sum is accumulated, term by term. • The result is a O(n) time operation, where n is the degree of the polynomial.
  • 17. Appending Terms • A tail reference in our linked list implementation for use by several of the polynomial arithmetic operations in order to perform fast append operations. • The appendTerm() helper method in lines accepts the degree and coefficient of a polynomial term, creates a new node to store the term, and appends the node to the end of the list.
  • 18. Polynomial Addition • The new polynomial is created by iterating over the two original polynomials, term by term, from the largest degree among the two polynomials down to degree 0. • The element access method is used to extract the coefficients of corresponding terms from each polynomial, which are then added, resulting in a term for the new polynomial. • Since we iterate over the polynomials in decreasing degree order, we can simply append the new term to the end of the linked list storing the new polynomial.

Editor's Notes

  1. T2-Pg no 180