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
How many loops are there in c?
Do pointers store the address of value or the actual value of a variable?
What is advantage of pointer in c?
Write a Program to find whether the given number or string is palindrome.
Explain how can you check to see whether a symbol is defined?
What is #line?
Function calling procedures? and their differences? Why should one go for Call by Reference?
Is null always equal to 0(zero)?
console I/O functions means a) the I/O operations done on disk b) the I/O operations done in all parts c) the input given through keyboard is displayed VDU screen d) none of the above
What are the benefits of c language?
What are global variables?
What does it mean when a pointer is used in an if statement?
Write a program of prime number using recursion.
Describe how arrays can be passed to a user defined function
What is static identifier?