Why did we use self loop?
Insertion in circular LL
which self loop?
can you share the code in which you confuse or got error
at which line you have error
void insert(node*&head,int data)
{
//create a new node
noden=new node(data);
nodetemp=head;
n->next=head;
if(temp!=NULL)
{
while(temp->next!=head)
{
temp=temp->next;
}
temp->next=n;
}
//applying self loop
else
n->next=n;
head=n;
}
here why did we apply the else condition
this is for circular LL
self loop is applied only when there is one element
if we add a element first time then temp ==NULL
hence we apply self loop
to make the LL circular
i hope it’s clear now
NOTE
try to ask doubt on the question in which you have doubt
for example
in this doubt you have asked your doubt on the problem
[circular-linked-list-ii-delete-function]
hence it is not clear what you want to ask