0% found this document useful (0 votes)
2 views

BSCS_CS213

A linked list is a dynamic data structure where each element, or node, is connected to the next, allowing for efficient memory usage and easy insertion and deletion. There are four types of linked lists: singly linked, doubly linked, circular, and doubly circular, each with unique traversal capabilities and advantages. However, linked lists have disadvantages such as memory overhead for pointers, limited random access, and slower search times compared to arrays.

Uploaded by

jazztice13jay
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)
2 views

BSCS_CS213

A linked list is a dynamic data structure where each element, or node, is connected to the next, allowing for efficient memory usage and easy insertion and deletion. There are four types of linked lists: singly linked, doubly linked, circular, and doubly circular, each with unique traversal capabilities and advantages. However, linked lists have disadvantages such as memory overhead for pointers, limited random access, and slower search times compared to arrays.

Uploaded by

jazztice13jay
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/ 13

LINKED LIST

G1 BSCS-2CSE CS-213
What is a Linked list?
◦A data structure called a linked list uses a chain to hold data.
Every piece of data in a linked list is connected to every other
piece of data (and perhaps to the data before it as well)
because of the way the list is structured. A node is any
element in a linked list. Imagine it as a real chain, with each
ring or node connected to the next. Something along these
lines.
ADVANTAGES
- Dynamics: Think of a linked list as a chain of connected boxes. Each box
contains an element and a pointer to the next box. When a customer adds an
item, you simply add a new box to the chain. If it deletes an item, you delete
the corresponding box. This dynamic nature allows linked lists to grow or
shrink as needed, unlike fixed-size arrays.
- Efficient: Because you only allocate memory for the boxes you need, you
avoid wasting space like you would with an array that requires space for a
maximum number of elements. This makes linked lists memory efficient,
especially when dealing with unpredictable data sizes.
- Easy redraft: Adding a new item to a shopping cart (inserting into a linked
list) is as simple as creating a new box, linking it to the previous box, and
updating the pointer. Deleting an item is just as easy.
- Versatile: Linked lists are the building blocks of more complex data
structures. Stacks (think of a stack of disks) and queues (like a queue in
a store) are both implemented using linked lists. Trees and graphs used
to represent relationships between data are also based on linked lists.
- Scalability: Adding a new element to the end of a linked list is a
constant-time operation, meaning it takes the same amount of time
regardless of the number of elements already in the list. This makes
linked lists scalable to handle large amounts of data.
DISADVANTAGES
- Memory cost: Each instance in a linked list requires additional memory for the pointer
to the next instance. This can be a disadvantage if you are working with limited memory.
- Limited random access: Imagine you want to find the 5th item in a shopping cart.
With a linked list, you have to start from the beginning and follow the pointers until you
get to the 5th item. This is called linear search and can be slow, especially for large lists.
- Search Complexity: Searching for a particular element in a linked list can be time
consuming, especially if the element is near the end of the list. In fact, you have to
traverse the entire list until you find the element.
- Backward Traversal: Navigating a linked list in reverse order (from the last element to
the first element) is inefficient and cannot be done in a singly linked list. You need to
store additional information about the previous element to achieve this.
Four types of linked lists:

- Singly linked list

- Doubly linked list

- Circular linked list

- Doubly Circular linked list.


Singly Linked List
- Singly Linked List: In a singly linked
list, each node contains a reference to
the next node in the sequence. This
structure allows for traversal in only
one direction, starting from the head
node and moving towards the tail
node. Singly linked lists are efficient in
terms of memory usage but have
limitations in reverse traversal.
Example:
1 -> 2 -> 3 -> 4 -> 5 -> NULL
Doubly Linked List
- Doubly Linked List: Doubly linked lists
extend the functionality of singly linked lists
by including a reference to both the next and
previous nodes in each node. This
bidirectional connectivity enables traversal in
both directions, making operations like
insertion and deletion more efficient than
singly linked lists.
Example:
NULL <-> 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> NULL
Circular Linked List
- Circular Linked List: In a circular
linked list, the last node points back to
the first node, creating a loop in the
sequence. This circular structure allows
for seamless traversal from the last
node to the first node, offering
advantages in certain applications like
round-robin scheduling.
Example:
1 -> 2 -> 3 -> 4 -> 5 -> 1
Double Circular Linked List
- Doubly Circular Linked List: The doubly circular
linked list combines the bidirectional traversal of
doubly linked lists with the circular structure of
circular linked lists. Each node has references to
both the next and previous nodes, and the last
node points back to the first node. This combination
provides the benefits of bidirectional traversal and
circular connectivity.
Example:
NULL <-> 1 <-> 2 <-> 3 <-> 4 <-> 5 <-> 1 <-> NULL
GROUP 1 MEMBERS
◦Alexis S. Dumpa

◦Charline T. Santos
REFERENCES
◦https://www.freecodecamp.org/news/introduction-to-linked-lists-in-pytho
n/

◦https://www.geeksforgeeks.org/introduction-to-linked-list-data-structure/

◦https://www.simplilearn.com/tutorials/data-structure-tutorial/types-of-link
ed-list

You might also like