How can you calculate number of nodes in a circular Linked List?

Showing Answers 1 - 12 of 12 Answers

Ashok S Meti

  • Apr 29th, 2006
 

using rear and front pointer...........

  Was this answer useful?  Yes

santosh kumar routhu

  • May 23rd, 2006
 

struct node

{  int data;

   struct node *next;

};

i write just function here

int count(struct node *pp)

{  struct node *start;

  int count=0;

   start=pp->next;

  while(start->next!=pp)

  { start=start->next;  

   count++; }

  return count;

}

here count gives no of nodes in that list

Hanumantappa

  • May 31st, 2006
 

int count(struct node *q){int i;while(q!=null){i++;q=q->next;}return (i);}

  Was this answer useful?  Yes

sunil kumar

  • Jan 22nd, 2007
 

we cant find the node having next =NULL
then how we can find the number fo node in cir link list
(if any comment plz mail me)

  Was this answer useful?  Yes

fairy

  • Apr 26th, 2007
 

how can u check for NULL...in circular list the next node will never be null

  Was this answer useful?  Yes

c.s.arthe

  • Aug 23rd, 2016
 

If the first node you have started with, comes again in the traversal, we can stop counting. Instead of null we can check next!=first.

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions