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
What is int main () in c?
Explain how do you list a file’s date and time?
What is cohesion and coupling in c?
The postoder traversal is 7,14,3,55,22,5,17 Then ur Inorder traversal is??? please help me on this
What is function pointer c?
Which of the following operators is incorrect and why? ( >=, <=, <>, ==)
When c language was developed?
Do variables need to be initialized?
To print the pattern 1 2 3 4 5 10 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9
What are the valid places to have keyword “break”?
What is difference between constant pointer and constant variable?
write a program to concatenation the string using switch case?
What is #define?
What is structure in c explain with example?
what are the 10 different models of writing an addition program in C language?