int countNodes() //to display the number of nodes
{
int c=0;
Node ptr=this;
while(ptr.link!=null)
{
c=c+1;
ptr=ptr.link;
}
c=c+1;
return c;
}
Solved PYQs, Programs, Circuits & Guides
int countNodes() //to display the number of nodes
{
int c=0;
Node ptr=this;
while(ptr.link!=null)
{
c=c+1;
ptr=ptr.link;
}
c=c+1;
return c;
}