Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.
Answer Posted / jishu
Answer 6 is correct and well thought but there is a tiny
mistake.
the while loop should check upto the last node which it
doesn't and hence prints the wrong value ie. value of the
node before the fifth node from the end.
while(p!=NULL) would give the correct node.
Also while returning the value, decrementing curr_ct by 5 is
not really necessary.
return a[curr_ct%5]; would give the same value in all cases.
Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
What is malloc and calloc?
What is the use of volatile?
Is there any possibility to create customized header file with c programming language?
What is the meaning of c in c language?
How do I swap bytes?
What is formal argument?
Who is the main contributor in designing the c language after dennis ritchie?
void main(int n) { if(n==0) return; main(--n); printf("%d ",n); getch(); } how it work and what will be its output...............it any one know ans plz reply
What does %c do in c?
Explain heap and queue.
What is the advantage of using #define to declare a constant?
Write a program to swap two numbers without using the third variable?
When would you use a pointer to a function?
How can I run c program?
Write a c program to build a heap method using Pointer to function and pointer to structure ?