LINKED
LIST
{
}
...
WHAT IS LINKED LIST?
A Linked list is a linear data structure where each
is a separate objects, known as a node. each node
contains some data and points to the next node in the
structure, forming sequence.
This structure allows for efficient insertion or removal of
elements from any position as only the link is needed to
be modified to point to some other element.
The Node
Each node in its basic contains has two
portions; the data, and references to the next
node in the sequence.
In C, we define node as a structure that has
the data and the reference pointer
information.
ADVANTAGES OVER AN ARRAY NODE
1.Not fixed in size: linked list are not fixed in size unlike
that of arrays, hence they can grow and shrink depending
on the data to be inserted. only the amount of memory
required to store the data is used.
2.Efficient insertion and deletion: insertion and deletion
are efficient and take constant time as only the links are
manipulated, not the actual memory location of the actual
elements.
DISADVANTAGES OVER AN ARRAY
1.Slightly more memory usage: as each element has to store its data
along with the reference information.
2. Sequential access; nodes in a linked list must be read in order from the
beginning as linked list are inherently sequential access.
3.Difficult reverse traversal; difficulties arise In linked list when it comes to
reverse traversing in a singly linked list. This can be resolved using
doubly linked lists, but this again increase memory as we have to store
the previous reference pointer.
ACCESSING AN ELEMENT IN A LINKED
LIST
An element in a linked list cannot be accessed directly,
unlike an array. Thus, one has to traverse from one end
of the linked list to the element that has to be accessed.
This is what causes the average O(n) search and access
time in a linked list. Insertion and deletion on the other
hand is constant time as only a few pointers have to be
modified
Uses of a linked list
1. Implement other data structures: It is used to
implement other data structures such as stacks,
queues and non-linear ones like trees and
graphs.
2. Hash Chaining: It has uses in hash chaining
for the implementation in open chaining.
Singly Linked List
A singly list is the simplest type of
linked list in which every node contains
some data and a pointer to the next
node. A singly linked list allows traversal
of data only in one way.
Singly Linked List
Doubly Linked List
A doubly linked list is a data structure which
consists of nodes which have data, a pointer to the
next node, and also a pointer to the previous
node. Three ways of inserting a node in a doubly
linked list in C++ are: Insertion of node at the
front of the list. Insertion of node after a given
node of the list.
Doubly Linked List
Circular Linked List
In a circular linked list, the last node contains a pointer
to the first node of the list, forming a loop.
While traversing a circular linked list, we can begin at
any node and traverse the list in any directions, forward or
backward, until we reach the same mode we started.
Thus, a circular linked list has no beginning and no
ending.
Circular Linked List
THANK
YOU!
{
} ..
..
DSA-Linked-List-.. learning process.pptx

DSA-Linked-List-.. learning process.pptx

  • 1.
  • 2.
    WHAT IS LINKEDLIST? A Linked list is a linear data structure where each is a separate objects, known as a node. each node contains some data and points to the next node in the structure, forming sequence. This structure allows for efficient insertion or removal of elements from any position as only the link is needed to be modified to point to some other element.
  • 3.
    The Node Each nodein its basic contains has two portions; the data, and references to the next node in the sequence. In C, we define node as a structure that has the data and the reference pointer information.
  • 4.
    ADVANTAGES OVER ANARRAY NODE 1.Not fixed in size: linked list are not fixed in size unlike that of arrays, hence they can grow and shrink depending on the data to be inserted. only the amount of memory required to store the data is used. 2.Efficient insertion and deletion: insertion and deletion are efficient and take constant time as only the links are manipulated, not the actual memory location of the actual elements.
  • 5.
    DISADVANTAGES OVER ANARRAY 1.Slightly more memory usage: as each element has to store its data along with the reference information. 2. Sequential access; nodes in a linked list must be read in order from the beginning as linked list are inherently sequential access. 3.Difficult reverse traversal; difficulties arise In linked list when it comes to reverse traversing in a singly linked list. This can be resolved using doubly linked lists, but this again increase memory as we have to store the previous reference pointer.
  • 6.
    ACCESSING AN ELEMENTIN A LINKED LIST An element in a linked list cannot be accessed directly, unlike an array. Thus, one has to traverse from one end of the linked list to the element that has to be accessed. This is what causes the average O(n) search and access time in a linked list. Insertion and deletion on the other hand is constant time as only a few pointers have to be modified
  • 7.
    Uses of alinked list 1. Implement other data structures: It is used to implement other data structures such as stacks, queues and non-linear ones like trees and graphs. 2. Hash Chaining: It has uses in hash chaining for the implementation in open chaining.
  • 8.
    Singly Linked List Asingly list is the simplest type of linked list in which every node contains some data and a pointer to the next node. A singly linked list allows traversal of data only in one way.
  • 9.
  • 10.
    Doubly Linked List Adoubly linked list is a data structure which consists of nodes which have data, a pointer to the next node, and also a pointer to the previous node. Three ways of inserting a node in a doubly linked list in C++ are: Insertion of node at the front of the list. Insertion of node after a given node of the list.
  • 11.
  • 12.
    Circular Linked List Ina circular linked list, the last node contains a pointer to the first node of the list, forming a loop. While traversing a circular linked list, we can begin at any node and traverse the list in any directions, forward or backward, until we reach the same mode we started. Thus, a circular linked list has no beginning and no ending.
  • 13.
  • 14.