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

Linked List Intro

This document discusses different types of linked lists including singly linked lists, doubly linked lists, and circular linked lists. It provides details on the structure of each type of linked list through diagrams and explanations of key terms like links, next pointers, and previous pointers. It also summarizes common operations that can be performed on each type of linked list such as insertion, deletion, traversal, and searching. Circular linked lists are noted as being useful for implementing queues and allowing traversal from any starting point in the list.

Uploaded by

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

Linked List Intro

This document discusses different types of linked lists including singly linked lists, doubly linked lists, and circular linked lists. It provides details on the structure of each type of linked list through diagrams and explanations of key terms like links, next pointers, and previous pointers. It also summarizes common operations that can be performed on each type of linked list such as insertion, deletion, traversal, and searching. Circular linked lists are noted as being useful for implementing queues and allowing traversal from any starting point in the list.

Uploaded by

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

Subject: Data Structures and

Analysis of Algorithms
Topic : Linked Lists

Prepared by
Mrs. D.Princy,
Assistant Professor,
Department of Computer Technology,
Kongunadu Arts and Science College,
Coimbatore – 29.
Data Structure
 A data structure is a data organization,
management, and storage format that
enables efficient access and modification.

The implementation of a data structure usually


requires writing a set of procedures that create and
manipulate instances of that structure.
Types of Data Structures
There are numerous types of data structures,
generally built upon simpler primitive data types:
 Array
 Linked List
 Record
 Union
 Object
 Graphs
 Binary Trees
Linked List Data Structure
Like arrays, Linked List is a linear data structure.
Unlike arrays, linked list elements are not stored at
contiguous location; the elements are linked using
pointers.
Types of Linked List
Singly Linked List − Item navigation is forward
only.

Doubly Linked List − Items can be navigated


forward and backward.

Circular Linked List − Last item contains link of


the first element as next and the first element has a
link to the last element as previous.
Singly Linked List
 A linked list is a sequence of data structures, which are
connected together via links.
 Linked List is a sequence of links which contains items.
Each link contains a connection to another link. Linked
list is the second most-used data structure after array.
 Important terms of Linked List.
 Link − Each link of a linked list can store a data called an
element.
 Next − Each link of a linked list contains a link to the next
link called Next.
 LinkedList − A Linked List contains the connection link to
the first link called First.
Singly Linked List Representation
 Linked list can be visualized as a chain of nodes, where
every node points to the next node.

 As per the above illustration, following are the important


points to be considered.
 Linked List contains a link element called first.
 Each link carries a data field(s) and a link field called
next.
 Each link is linked with its next link using its next link.
 Last link carries a link as null to mark the end of the list.
Basic Operations
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.
Doubly Linked List
Doubly Linked List is a variation of Linked list in
which navigation is possible in both ways, either
forward and backward easily as compared to Single
Linked List.
Following are the important terms to understand the
concept of doubly linked list.
 Link − Each link of a linked list can store a data called an
element.
 Next − Each link of a linked list contains a link to the next
link called Next.
 Prev − Each link of a linked list contains a link to the previous
link called Prev.
 LinkedList − A Linked List contains the connection link to
the first link called First and to the last link called Last.
Doubly Linked List Representation

 As per the above illustration, following are the important


points to be considered.
 Doubly Linked List contains a link element called first and last.
 Each link carries a data field(s) and two link fields called next
and prev.
 Each link is linked with its next link using its next link.
 Each link is linked with its previous link using its previous
link.
 The last link carries a link as null to mark the end of the 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.
 Insert Last − Adds an element at the end of the list.
 Delete Last − Deletes an element from the end of the list.
 Insert After − Adds an element after an item of the list.
 Delete − Deletes an element from the list using the key.
 Display forward − Displays the complete list in a forward
manner.
 Display backward − Displays the complete list in a
backward manner.
Advantages over singly linked list
1. A DLL can be traversed in both forward and
backward direction.
2. The delete operation in DLL is more efficient if
pointer to the node to be deleted is given.
3. We can quickly insert a new node before a given
node.
In singly linked list, to delete a node, pointer to the
previous node is needed. To get this previous node,
sometimes the list is traversed. In DLL, we can get
the previous node using previous pointer.
Disadvantages over singly linked
list
1. Every node of DLL Require extra space for an
previous pointer.

2. All operations require an extra pointer previous


to be maintained. For example, in insertion, we
need to modify previous pointers together with
next pointers.
Circular Linked List
 Circular linked list is a linked list where all nodes are
connected to form a circle. There is no NULL at the end. A
circular linked list can be a singly circular linked list or
doubly circular linked list.
 Circular Linked List is a variation of Linked list in which
the first element points to the last element and the last
element points to the first element.
Singly Linked List as Circular
In singly linked list, the next pointer of the last node points
to the first node.
Doubly Linked List as Circular
 In doubly linked list, the next pointer of the last node
points to the first node and the previous pointer of the first
node points to the last node making the circular in both
directions.
 The last link's next points to the first link of the list in both
cases of singly as well as doubly linked list.
 The first link's previous points to the last of the list in case
of doubly linked list.
Basic Operations
Following are the important operations supported by a
circular list.
 insert − Inserts an element at the start of the list.

 delete − Deletes an element from the start of the list.

 display − Displays the list.


Advantages of Circular Linked
Lists
1) Any node can be a starting point. We can traverse the
whole list by starting from any point. We just need to
stop when the first visited node is visited again.
2) Useful for implementation of queue
3) Circular lists are useful in applications to repeatedly
go around the list.
4) Circular Doubly Linked Lists are used for
implementation of advanced data structures
like Fibonacci Heap.

You might also like