Posts

Showing posts from October 15, 2017

Doubly Linked List

Image
Doubly linked list is an another Data Structure, that is an advance version of singly linked list. In this data structure, a node can have previous and next pointer that allows the list to be traverse in both the direction. Doubly Linked List: Each node point not only its successor(previous) but the predecessor(next) There are two NULL point that is at last node next and at the first node prev. Easy to traverse the list in both the direction Advantage over singly Linked List   Doubly link list allow the traversal in both the direction. Therefore, suitable for sorting the elements of the list.  Disadvantage over singly Linked List Every node of DLL required extra space to store another prev pointer. All operation required additional pointer to previous to be maintained   Implementation of structure #include #include struct node { int data; struct node *prev,*next; }*head=NULL,*temp=NULL; struct node *createNode() { int n; struct node *newNode=(struct nod