DSPD PPT Group 3
DSPD PPT Group 3
AND TECHNOLOGY
UNIT 3
Representation of
Ordered List Using an
Array
A detailed overview with examples and visuals
Definition of Ordered List
• An ordered list is a collection of elements arranged in a specific order.
• Index: 0 1 2 3 4
• Array: 10 20 30 40 50
Applications of Ordered Lists
• • Used in searching algorithms (Binary Search requires a sorted list).
• • Database management systems for indexing and retrieval.
• • Scheduling tasks in operating systems.
• • Storing sorted datasets in scientific computing.
Conclusion
• • Ordered lists maintain a specific sequence of elements.
• • Arrays provide an efficient way to store and manage ordered lists.
• • Indexing allows quick access and modification of elements.
• • Ordered lists are widely used in computing and data management.
Operation On
Ordered List
Insertion
The next of the last node is null, indicating the end of the list.
Linked Lists support efficient insertion and deletion operations.
Characteristics:
•Head:
• Singly The
linked listfirst node in the list. It’s used to access the entire
list. linked list
• Singly
•Tail: The last node in the list. Its next pointer points to null (or None in
Python), indicating the end of the list.
•Traversal: The list can be traversed from the head node, following the
next pointers until the end is reached (when next is null).
Understanding Node
Structure
In a singly linked list, each node
consists of two parts: data and a pointer to the next node. This
structure allows nodes to be dynamically linked together, forming
a chain-like sequence
Operations on a Singly Linked List:
• Singly linked list
•Insertion: Adding a new node at the beginning, end, or a specific
• Singly list
position.
•Deletion: Removing a node from the beginning, end, or a specific
position.
•Traversal: Visiting each node to read its data.
•Search: Finding a node by value.
•Reversal: Reversing the entire list.
advantages and
disadvantages
Advantage
• Accessing of a node in the forward direction is easier.
• Insertion and Deletion of nodes are easier
Disadvantages
• Accessing the preceding node of a current node is not possible
as there is no backward traversal.
• Accessing a node is time consuming
Static Linked List
Implementation
Using Static Memory Allocation in C
Introduction
What is a Linked List?
• - A data structure consisting of nodes, where each node stores data and a
reference to the next node.
• - Typically implemented using dynamic memory allocation, but can also be
implemented statically.
Example:
#define MAX_NODES 3
Node list[MAX_NODES] = {
{10, 1}, // Node at index 0
{20, 2}, // Node at index 1
{30, -1} // Node at index 2 (last node)
};
Implementation Steps
1. Initialize the List
• - Create a free list to manage available nodes.
2. Insertion Process
• - Allocate a free node from the pre-defined array.
• - Update next pointers to maintain the linked structure.
3. Deletion Process
• - Remove a node and return it to the free list.
• - Adjust next pointers to preserve the list structure.
Example Functions:
• void insertEnd(int data);
• void deleteNode(int key);
• void displayList();
Advantages & Limitations
✅ Advantages:
• - No need for malloc() and free(), avoiding fragmentation.
• - Faster allocation as memory is pre-allocated.
• - Useful in memory-constrained environments.
❌ Limitations:
• - Fixed size: Cannot dynamically expand.
• - Memory wastage: If not all nodes are used, some memory is wasted.
• Conclusion:
• - Best suited for embedded systems and applications requiring predictable memory usage.
What is a Polynomial?
• A polynomial is a mathematical expression involving a sum of powers
of a variable, each multiplied by a coefficient. It can be written in the
form:
• Where:
• P(x) is the polynomial in terms of the variable xxx.
an,an−1,…,a1,a0are the coefficients of the polynomial (which are
usually real numbers).
• x is the variable or indeterminate.
• n is the degree of the polynomial, which is the highest power of x with
a non-zero coefficient.
23
Why Use Linked Lists for
Polynomials?
24
Operations on Polynomials Using Linked
Lists
• Addition of Polynomials:
• Traverse both polynomial lists, comparing exponents.
• Add coefficients of matching exponents.
• Multiplication of Polynomials:
• Multiply each term of one polynomial with every term of the other
polynomial.
• Add the results accordingly.
• Traversal:
• Traverse through the linked list to evaluate the polynomial or perform
other operations.
25
Advantages and Applications
26
Introduction to Doubly Linked Lists