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
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
Can you apply link and association interchangeably?
What is the difference between Printf(..) and sprint(...) ?
5 Write an Algorithm to find the maximum and minimum items in a set of ānā element.
What is the significance of c program algorithms?
What kind of structure is a house?
how to execute a program using if else condition and the output should enter number and the number is odd only...
Write a program to input the price of 1 burger and the number of burgers eaten by a group of friends .print the total amount to be paid by the group?
What is clrscr ()?
Do pointers store the address of value or the actual value of a variable?
write a program in C that prompts the user for today's date,tomorrow's date and display the results.Use structures for today's date,tomorrow's date and an array to hold the days for each month of the year.
Tell me can the size of an array be declared at runtime?
what is a constant pointer in C
What is pass by reference in c?
What is the benefit of using #define to declare a constant?