1,009 views
2 votes
2 votes

int find (struct node * first, int n) 
{ 
while (first data ! = n) 
first = first — next;
if (first data = = n)
  return(1);
else 
 return (-1); 

 

in the above code segment if the value of 'n' is 5, then the function return 1, but if the value of 'n' is 9, then what does it do ? 

1 Answer

0 votes
0 votes
here it will go to infinite loop because of circular nature but what if it is not circular then i guess it will return -1 because 9 is not  present in the linked list.

Related questions