Week 9
Week 9
CSO102
WEEK-9 (DRAFT)
LINKED LIST:
Each node consists of two fields: one field has data, and in the
second field, the node has an address that keeps a reference to the
next node.
LINKED LIST: ADVANTAGES
RANDOM ACCESS
COMPLEX IMPLEMENTATION
LINKED LIST: POSSIBLE CASES OF
INSERTION
SN Operation Description
1 Insertion at beginning Adding a node into circular singly linked list at the
beginning.
2 Insertion at the end Adding a node into circular singly linked list at the
end.
CIRCULAR LINKED LIST: Deletion
SN Operation Description
1 Deletion at beginning Removing the node from circular singly linked list at
the beginning.
2 Deletion at the end Removing the node from circular singly linked list at
the end.
3 Searching Compare each element of the node with the given
item and return the location at which the item is
present in the list otherwise return null.
4 Traversing Visiting each element of the list at least once in
order to perform some specific operation.
DOUBLY LINKED LIST
There are two NULL: at the first and last nodes in the list
struct Node
{
int data;
struct Node *next;
struct Node *prev;
};
DOUBLY LINKED LIST: C implementation
COMPONENTS:
Circular Doubly Linked List has properties of both doubly linked list
and circular linked list.
Two consecutive elements are linked or connected by the previous
and next pointer and the last node points to the first node by the next
pointer and also the first node points to the last node by the previous
pointer.
CIRCULAR DOUBLY LINKED LIST
-create
-insert(beginng, end, middle)
-delete (beginng, end, middle)
-search
-traverse
POLYNOMIAL ADDITION USING LINKED
LIST:
return result;
}
POLYNOMIAL ADDITION(3 variables):
struct Node
{
float coeff;
int powX;
int powY;
int powZ;
struct Node* next;
};
POLYNOMIAL MULTIPLICATION:
Input:
Poly2: 6x^1 + 8
ALGORITHM
Multiply the 2nd polynomial with each term of 1st
polynomial.
- String reversal
Notations for Arithmetic Expression:
Infix Notation
Prefix Notation
Postfix Notation
Infix Notation
Example: A + B, C - D etc.
Prefix Notation: