Wednesday, 26 July 2017

Circular Doubly Linked List - Deletion algorithm


Deleting the First Node from a Circular Doubly Linked List Algorithm

Step 1: If the linked list is empthy (START == NULL)

Write "Sorry Buddy there is no node"

Step 2: If the linked list have only one node (START -> NEXT == START -> PREV)

free(START)
START = NULL

Step 3: If the list have more than one node

PTR = START;
while(PTR ->NEXT != START)
{

PTR = PTR ->NEXT

}
PTR -> NEXT = START -> NEXT
PTR -> NEXT -> PREV =PTR
free(START);
START = PTR ->NEXT

Step 4 : EXIT

Deleting the Last Node from a Circular Doubly Linked List Algorithm

Step 1: If the linked list is empthy (START == NULL)

Write "Sorry Buddy there is no node"

Step 2: If the linked list have only one node (START -> NEXT == NULL)

free(START);
START = NULL

Step 3: If the list have more than one node

PTR = START
while(PTR -> NEXT != START)
{
PTR = PTR -> NEXT }
PTR -> PREV -> NEXT = START
START -> PREV = PTR ->PREV
free(PTR)

Step 4 : EXIT

Share this

0 Comment to "Circular Doubly Linked List - Deletion algorithm"

Post a Comment