CROCOCHOCOBARROSHAN
2,681 views
6 slides
Nov 22, 2014
Slide 1 of 6
1
2
3
4
5
6
About This Presentation
No description available for this slideshow.
Size: 756.56 KB
Language: en
Added: Nov 22, 2014
Slides: 6 pages
Slide Content
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.