Linked Lists
Linked Lists
Introduction
• A linked list is a series of connected nodes
• Each node has two parts
– A piece of data [INFO]
– Pointer to the next node in the list [LINK]
• Successive nodes are connected by pointers.
• Last node points to NULL.
• It can grow or shrink in size during execution of a program.
• It can be made just as long as required.
• It does not waste memory space.
• Head: pointer to the first node
• The last node points to NULL
Introduction
Head=NULL
indicates that the list is empty
Introduction
• Keeping track of a linked list:
– Must know the pointer to the first element of the
list (called start, head, etc.).
tmp X Item to be
inserted
A B C
curr
tmp
curr
A B C
INFO LINK
Polynomial Representation
Nodes are linked according to decreasing
degree
Addition of two Polynomials
P=5x2+4x+2
Q=5x+5
Multiplication of two polynomials
Addition of two polynomials (Algorithm)
Node Structure for 3 variables
Example: 3x2+2xy2+5y3+7yz