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
Define circular linked list.
What is wrong with this declaration?
Explain why c is faster than c++?
Explain how can I manipulate strings of multibyte characters?
Create a simple code fragment that will swap the values of two variables num1 and num2.
Write a code to generate a series where the next element is the sum of last k terms.
What is static memory allocation?
typedef enum { html, java, javascript, perl, cgi } lang;The above statement defines a : a) Union b) User defined type c) Enumerated variable d) none
Why void is used in c?
What are the types of functions in c?
What does d mean?
What are global variables and how do you declare them?
Please send me WIPRO technical question to my mail ID.. its nisha_g28@yahoo.com please its urgent
What is a global variable in c?
How many keywords (reserve words) are in c?