0% found this document useful (0 votes)
25 views19 pages

Linked List

The document provides an overview of linked lists, a linear data structure used for storing collections of data in nodes. It covers terminology, primitive operations (insertion, deletion, traversal), representation, and variants of linked lists including singly, doubly, and circular linked lists. Additionally, it discusses the advantages of linked lists such as dynamic sizing and efficient memory utilization.

Uploaded by

madhulikathrasu
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)
25 views19 pages

Linked List

The document provides an overview of linked lists, a linear data structure used for storing collections of data in nodes. It covers terminology, primitive operations (insertion, deletion, traversal), representation, and variants of linked lists including singly, doubly, and circular linked lists. Additionally, it discusses the advantages of linked lists such as dynamic sizing and efficient memory utilization.

Uploaded by

madhulikathrasu
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/ 19

Module 3

Linked Lists
Linked Lists
 Linked Lists-Terminology
 Primitive Operations- creating, inserting , deleting,
traversing
 Representation of Linked Lists
 Linked List Abstract Data Type
 Linked List Variants - Singly Linked List
 Applications of Linked List
 Linked repetitions of stacks and queues
 Doubly Linked Lists
 Circular Linked List
• A linked list is a linear data structure used for
storing collections of data in the form
of nodes. Each node in a linked list store two
elements – data and address of next node
• A linked list is a linear data structure, in which
the elements are not stored at contiguous
memory locations.
Linked Lists
• The last node contains null in its second field
because it will point to no node.
• A linked list can grow and shrink its size, as per
the requirement.
• It does not waste memory space
Representation of a Linked List

• Here, the start pointer stores the address of


the first node, and at the end, there is a null
pointer that states the end of the Linked List.
Uses of Linked List
• The list is not required to be contiguously
present in the memory. The node can reside
any where in the memory and linked together
to make a list. This achieves optimized
utilization of space.
• list size is limited to the memory size and
doesn't need to be declared in advance.
• Empty node can not be present in the linked
list.
Basic Operations

Following are the basic operations supported by a list.


• Insertion − Adds an element at the beginning of the
list.
• Deletion − Deletes an element at the beginning of
the list.
• Display − Displays the complete list.
• Search − Searches an element using the given key.
• Delete − Deletes an element using the given key
Types of Linked Lists

The linked list mainly has three types, they are:


Singly Linked List
Doubly Linked List
Circular Linked List
Singly Linked List

• A singly linked list is the most common type of


linked list. Each node has data and an address
field that contains a reference to the next
node
Doubly Linked List

• There are two pointer storage blocks in the doubly linked


list.
• The first pointer block in each node stores the address of
the previous node.
• Hence, in the doubly linked inventory, there are three
fields that are the previous pointers, that contain a
reference to the previous node.
• Then there is the data, and last you have the next pointer,
which points to the next node.
• Thus,we can go in both directions (backward and
forward).
Circular Linked List

• The circular linked list is extremely similar to


the singly linked list. The only difference is that
the last node is connected with the first node,
forming a circular loop in the circular linked
list
Linked List reference Video
• (615) Building of Single Linked List ( Step By St
ep Animation ) - YouTube
Insert at begin
Algorithm:
• Make the first node of Linked List linked to the
new node
• Remove the head from the original first node
of Linked List
• Make the new node as the Head of the Linked
List.
Insert at End
Algorithm:
• Go to the last node of the Linked List
• Change the next pointer of last node from
NULL to the new node
• Make the next pointer of new node as NULL to
show the end of Linked List
Insert at Specific Position
Algorithm:
• Traverse the Linked list upto position-1 nodes.
• Once all the position-1 nodes are traversed,
allocate memory and the given data to the new
node.
• Point the next pointer of the new node to the
next of current node.
• Point the next pointer of current node to the
new node.

You might also like