# Deletion in circular singly linked list at beginning

In order to delete a node in circular singly linked list, we need to make a few pointer adjustments.

There are three scenarios of deleting a node from circular singly linked list at beginning.

### Scenario 1: (The list is Empty)

If the list is empty then the condition head == NULL will become true, in this case, we just need to print underflow on the screen and make exit.

### Scenario 2: (The list contains single node)

If the list contains single node then, the condition head → next == head will become true. In this case, we need to delete the entire list and make the head pointer free. This will be done by using the following statements.

### Scenario 3: (The list contains more than one node)

If the list contains more than one node then, in that case, we need to traverse the list by using the pointer ptr to reach the last node of the list. This will be done by using the following statements.

At the end of the loop, the pointer ptr point to the last node of the list. Since, the last node of the list points to the head node of the list. Therefore this will be changed as now, the last node of the list will point to the next of the head node.

Now, free the head pointer by using the free() method in C language.

Make the node pointed by the next of the last node, the new head of the list.

In this way, the node will be deleted from the circular singly linked list from the beginning.

## Algorithm

• Step 1: IF HEAD = NULL
• Write UNDERFLOW
Go to Step 8
[END OF IF]

• Step 2: SET PTR = HEAD
• Step 3: Repeat Step 4 while PTR → NEXT != HEAD
• Step 4: SET PTR = PTR → next
• [END OF LOOP]

• Step 5: SET PTR → NEXT = HEAD → NEXT
• Step 7: SET HEAD = PTR → NEXT
• Step 8: EXIT ## C Function

Output

```1.Append List
2.Delete Node from beginning
3.Exit

Enter the item
12

Node Inserted
1.Append List
2.Delete Node from beginning
3.Exit

Node Deleted
```   