0% found this document useful (0 votes)
42 views33 pages

DSPD PPT Group 3

The document provides an overview of ordered lists and their representation using arrays, highlighting their characteristics, operations, and applications in computing. It also discusses singly linked lists, their structure, operations, advantages, and limitations, along with static linked list implementation in C. Additionally, it covers polynomials and their representation using linked lists, and concludes with an introduction to doubly linked lists, emphasizing their efficiency and applications.

Uploaded by

affansheikh672
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views33 pages

DSPD PPT Group 3

The document provides an overview of ordered lists and their representation using arrays, highlighting their characteristics, operations, and applications in computing. It also discusses singly linked lists, their structure, operations, advantages, and limitations, along with static linked list implementation in C. Additionally, it covers polynomials and their representation using linked lists, and concludes with an introduction to doubly linked lists, emphasizing their efficiency and applications.

Uploaded by

affansheikh672
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 33

ANJUMAN COLLEGE OF ENGINEERING

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.

• • Each element has a unique position in the list.


• • The order is maintained during insertion and deletion.
• • Ordered lists can be ascending or descending.
• • Examples: Roll numbers, rankings, sorted datasets.
Representation Using an Array
• In an array, an ordered list is stored in contiguous memory locations:

• • Each element is assigned a fixed position (index).


• • Indexing allows quick retrieval, insertion, and deletion.
• • Elements must be shifted during insertion/deletion to maintain
order.
• • Efficient access: O(1) for retrieval, O(n) for insertion/deletion.
Example of Ordered List in an Array
• Consider an ordered list of numbers in ascending order:

• • Ordered List: [10, 20, 30, 40, 50]


• • Stored in an array as follows:

• 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

• • Insert at beginning: Insert a new element at the


starting of the list.
• • Insert at end: Insert a new element at the end of the
list.
• • Insert at specific position: Insert a new element at a
specific position in the list.
Delation
• Delete from beginning: Delete an element from the
starting of the list.
• Delete from end: Delete an element from the end of the
list.
• Delete from specific position: Delete an element from a
specific position in the list.
Searching
• Linear search: Search for a specific element in the list.
• Binary search: Search for a specific element in the list,
but this only works on sorted lists.
Sorting
• Ascending order: Sort the list in ascending
order.
• Descending order: Sort the list in descending
order.
Singly linked list

A singly linked list is a fundamental data structure, it consists


of nodes where each node contains a data field and
a reference to the next node in the linked list.

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.

Why Use Static Allocation?


• - Uses a fixed-size array instead of dynamically allocated memory (malloc() in
C).
• - Useful in embedded systems where memory management needs to be
controlled.
Node Structure & Example
Node Structure in C:
typedef struct {
int data; // Stores the value
int next; // Index of the next node
} Node;

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​,a0​are 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?

• Efficient Storage for Sparse Polynomials: Only non-zero terms


are stored, saving memory.
• Dynamic Size: Linked lists grow and shrink as needed, unlike
arrays with fixed sizes.
• Efficient Operations: Easy to add, multiply, or differentiate
polynomials by traversing the list and adjusting terms.
• No Fixed Size Limitation: Can handle polynomials with a large
degree without wasting memory on zero terms.

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

• Advantages of Linked List Representation:


• Efficient storage for sparse polynomials.
• Dynamic memory allocation.
• Applications:
• Computer algebra systems (CAS).
• Numerical methods, signal processing, and cryptography.

26
Introduction to Doubly Linked Lists

In this presentation, we will explore doubly linked


lists, a fundamental data structure that allows for
efficient insertion and deletion operations. We will
discuss their efficiency, applications, and how
they compare to other data structures.
Understanding these concepts is crucial for
optimizing performance in various programming
scenarios.
Structure of Doubly Linked
Lists

A doubly linked list consists of nodes, where each


node contains a data field and two pointers: one
pointing to the next node and another to the
previous node. This structure allows traversal in
both directions, making it more versatile than
singly linked lists for certain operations.
Efficiency Analysis

The time complexity for insertion and


deletion operations in doubly linked
lists is O(1), provided you have a
pointer to the node. However,
searching for an element takes O(n)
time. This efficiency makes them
suitable for applications where
frequent modifications are required.
Applications in Programming

Doubly linked lists are widely used in applications


such as music playlists, browser history, and undo
functionality in software. Their ability to efficiently
manage data that requires frequent insertion and
removal makes them an excellent choice for
dynamic data management.
Advantages and
Disadvantages

While doubly linked lists offer


bidirectional traversal and efficient
modifications, they also incur additional
memory overhead due to the extra
pointer. Understanding these trade-offs is
essential for selecting the right data
structure for your specific needs.
In conclusion, doubly linked lists are a
powerful data structure that provides
flexibility and efficiency for various
applications. By understanding their
Conclusion structure and performance characteristics,
developers can make informed decisions on
when to implement them in their projects.
thank you

You might also like