Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.
Answer Posted / amol b
int return_fifth_from_end()
{
int a[5],curr_ct=0;
struct node *p;
p=head;
while(p->next!=NULL)
{
a[curr_ct%5]=p->val;
p=p->next;
curr_ct++;
}
if(curr_ct>=5)
return a[(curr_ct-5)%5];
else
return -1;
}
Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
‘ C’ PROGRAME TO SHOW THE TYPE OF TRANGLE BY ACCEPTING IT’S LENGTH .
What is the difference between malloc() and calloc()?
What do you know about the use of bit field?
What is a constant and types of constants in c?
What does static variable mean in c?
What is the use of typedef in structure in c?
What are conditional operators in C?
Is c++ based on c?
What are dangling pointers? How are dangling pointers different from memory leaks?
How can I remove the trailing spaces from a string?
Write a program to print factorial of given number without using recursion?
How can I manipulate individual bits?
What is the scope of static variable in c?
List at least 10 sorting methods indicating their average case complexity, worst case complexity and best case complexity.
What is "Duff's Device"?