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 does %p mean?
How will you write a code for accessing the length of an array without assigning it to another variable?
What is hungarian notation? Is it worthwhile?
What happens if header file is included twice?
Explain what is the concatenation operator?
i have to apply for the rbi for the post of officers. i need to know abt the entrance questions whether it may be aps or techinical....
Can we declare variables anywhere in c?
How does sizeof know array size?
Is flag a keyword in c?
write a program to reverse a every alternetive words in a string in a place. EX: Input is "this is the line of text" Output should be "shit is eht line fo text" Please any one tell me code for that.
Explain threaded binary trees?
write a c program to find the sum of five entered numbers using an array named number
What are the 5 organizational structures?
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What is the general form of function in c?