SlideShare a Scribd company logo
1 of 6
INSERTION 
IN 
CIRCULAR DOUBLY 
LINKED LIST 
BY 
Roshan Chaudhary
CIRCULAR DOUBLY LINKED LIST 
• Doubly Circular linked list has both the properties of doubly 
linked list and circular linked list. 
• Two consecutive elements are linked by previous and next 
pointer and the last node points to first node by next pointer 
and also the previous pointer of the head node points to the 
tail node.
Node traversal from any direction is possible and also 
jumping from head to tail or from tail to head is only one 
operation: head pointer previous is tail and also tail pointer 
next is head.
INSERTING A NODE 
function insertAfter(Node node, Node newNode) 
newNode.next = node.next 
newNode.prev = node 
node.next.prev = newNode 
node.next = newNode 
This simple function inserts a node into a doubly-linked 
circularly linked list after a given element.
INSERTING A NODE (CONT.) 
function insertEnd(List list, Node node) 
if list.lastNode == null 
node.prev := node 
node.next := node 
else 
insertAfter(list.lastNode, node) 
list.lastNode := node 
To insert at the beginning.
Thank you

More Related Content

What's hot

What's hot (20)

linked list in data structure
linked list in data structure linked list in data structure
linked list in data structure
 
Deque and its applications
Deque and its applicationsDeque and its applications
Deque and its applications
 
Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]Data Structures - Lecture 7 [Linked List]
Data Structures - Lecture 7 [Linked List]
 
Singly & Circular Linked list
Singly & Circular Linked listSingly & Circular Linked list
Singly & Circular Linked list
 
Heap sort
Heap sortHeap sort
Heap sort
 
Linked list
Linked listLinked list
Linked list
 
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 Data Structures - Lecture 9 [Stack & Queue using Linked List] Data Structures - Lecture 9 [Stack & Queue using Linked List]
Data Structures - Lecture 9 [Stack & Queue using Linked List]
 
Quick sort
Quick sortQuick sort
Quick sort
 
Data Structures with C Linked List
Data Structures with C Linked ListData Structures with C Linked List
Data Structures with C Linked List
 
Linked list
Linked listLinked list
Linked list
 
Singly linked list
Singly linked listSingly linked list
Singly linked list
 
Singly link list
Singly link listSingly link list
Singly link list
 
Threaded Binary Tree
Threaded Binary TreeThreaded Binary Tree
Threaded Binary Tree
 
Doubly linked list
Doubly linked listDoubly linked list
Doubly linked list
 
Queue
QueueQueue
Queue
 
Polynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptxPolynomial reppresentation using Linkedlist-Application of LL.pptx
Polynomial reppresentation using Linkedlist-Application of LL.pptx
 
trees in data structure
trees in data structure trees in data structure
trees in data structure
 
Linked List
Linked ListLinked List
Linked List
 
SEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMSSEARCHING AND SORTING ALGORITHMS
SEARCHING AND SORTING ALGORITHMS
 
Linked List - Insertion & Deletion
Linked List - Insertion & DeletionLinked List - Insertion & Deletion
Linked List - Insertion & Deletion
 

Viewers also liked

Non Linear Data Structures
Non Linear Data StructuresNon Linear Data Structures
Non Linear Data StructuresAdarsh Patel
 
Data structure
Data structureData structure
Data structureMohd Arif
 
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....Shail Nakum
 
Queue data structure
Queue data structureQueue data structure
Queue data structureanooppjoseph
 
Array in c language
Array in c languageArray in c language
Array in c languagehome
 
Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)Arvind Devaraj
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its typesNavtar Sidhu Brar
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked listsstudent
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTUREArchie Jamwal
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURESbca2010
 

Viewers also liked (16)

Non Linear Data Structures
Non Linear Data StructuresNon Linear Data Structures
Non Linear Data Structures
 
Doubly linked list (animated)
Doubly linked list (animated)Doubly linked list (animated)
Doubly linked list (animated)
 
Doubly Link List
Doubly Link ListDoubly Link List
Doubly Link List
 
Data structure
Data structureData structure
Data structure
 
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
TYPES DATA STRUCTURES( LINEAR AND NON LINEAR)....
 
Tower of Hanoi
Tower of HanoiTower of Hanoi
Tower of Hanoi
 
linked list
linked list linked list
linked list
 
(Binary tree)
(Binary tree)(Binary tree)
(Binary tree)
 
Complexity of Algorithm
Complexity of AlgorithmComplexity of Algorithm
Complexity of Algorithm
 
Queue data structure
Queue data structureQueue data structure
Queue data structure
 
Array in c language
Array in c languageArray in c language
Array in c language
 
Data structures (introduction)
 Data structures (introduction) Data structures (introduction)
Data structures (introduction)
 
Data structure and its types
Data structure and its typesData structure and its types
Data structure and its types
 
header, circular and two way linked lists
header, circular and two way linked listsheader, circular and two way linked lists
header, circular and two way linked lists
 
STACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURESTACKS IN DATASTRUCTURE
STACKS IN DATASTRUCTURE
 
DATA STRUCTURES
DATA STRUCTURESDATA STRUCTURES
DATA STRUCTURES
 

Similar to Doubly circular linked list

Similar to Doubly circular linked list (20)

linked-list.ppt
linked-list.pptlinked-list.ppt
linked-list.ppt
 
Doubly Linked List
Doubly Linked ListDoubly Linked List
Doubly Linked List
 
Linkedlist
LinkedlistLinkedlist
Linkedlist
 
data structures and applications power p
data structures and applications power pdata structures and applications power p
data structures and applications power p
 
Linked list (1).pptx
Linked list (1).pptxLinked list (1).pptx
Linked list (1).pptx
 
List data structure
List data structure List data structure
List data structure
 
List Data Structure
List Data StructureList Data Structure
List Data Structure
 
Link_List.pptx
Link_List.pptxLink_List.pptx
Link_List.pptx
 
Lec3-Linked list.pptx
Lec3-Linked list.pptxLec3-Linked list.pptx
Lec3-Linked list.pptx
 
Linked list and its operations - Traversal
Linked list and its operations - TraversalLinked list and its operations - Traversal
Linked list and its operations - Traversal
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Linked list
Linked listLinked list
Linked list
 
Insertion in singly linked list
Insertion in singly linked listInsertion in singly linked list
Insertion in singly linked list
 
linked list using c
linked list using clinked list using c
linked list using c
 
Linked list
Linked listLinked list
Linked list
 
Lecture 4 data structures and algorithms
Lecture 4 data structures and algorithmsLecture 4 data structures and algorithms
Lecture 4 data structures and algorithms
 

More from Roshan Chaudhary

More from Roshan Chaudhary (8)

Overview of cryptography
Overview of cryptographyOverview of cryptography
Overview of cryptography
 
Doubly circular linked list
Doubly circular linked listDoubly circular linked list
Doubly circular linked list
 
Unipolar
UnipolarUnipolar
Unipolar
 
Software copyright
Software copyrightSoftware copyright
Software copyright
 
Structure and function
Structure and functionStructure and function
Structure and function
 
Effects Of ICT
Effects Of ICTEffects Of ICT
Effects Of ICT
 
Pollution and Prevention
Pollution and PreventionPollution and Prevention
Pollution and Prevention
 
Hacking
HackingHacking
Hacking
 

Doubly circular linked list

  • 1. INSERTION IN CIRCULAR DOUBLY LINKED LIST BY Roshan Chaudhary
  • 2. CIRCULAR DOUBLY LINKED LIST • Doubly Circular linked list has both the properties of doubly linked list and circular linked list. • Two consecutive elements are linked by previous and next pointer and the last node points to first node by next pointer and also the previous pointer of the head node points to the tail node.
  • 3. Node traversal from any direction is possible and also jumping from head to tail or from tail to head is only one operation: head pointer previous is tail and also tail pointer next is head.
  • 4. INSERTING A NODE function insertAfter(Node node, Node newNode) newNode.next = node.next newNode.prev = node node.next.prev = newNode node.next = newNode This simple function inserts a node into a doubly-linked circularly linked list after a given element.
  • 5. INSERTING A NODE (CONT.) function insertEnd(List list, Node node) if list.lastNode == null node.prev := node node.next := node else insertAfter(list.lastNode, node) list.lastNode := node To insert at the beginning.