Node addBegin(int data)
{
Node temp = new Node();
temp.data=data;
if(this.link==null && this.data==0)
{ //if the entire linked list is empty
this.data=data;
return this;
}
else
{
Node ptr=this;
temp.link=ptr;
ptr=temp;
return ptr;
}
Solved PYQs, Programs, Circuits & Guides
Node addBegin(int data)
{
Node temp = new Node();
temp.data=data;
if(this.link==null && this.data==0)
{ //if the entire linked list is empty
this.data=data;
return this;
}
else
{
Node ptr=this;
temp.link=ptr;
ptr=temp;
return ptr;
}