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
With the help of using classes, write a program to add two numbers.
What is #define?
PROGRAM TO WRITE CONTENTS OF 1 FILE IN REVERSE TO ANOTHER FILE,PROGRAM TO COPY 1 FILE TO ANOTHER BY SPECIFYING FILE NAMES AS COMMAND LINE
What do you mean by dynamic memory allocation in c?
What is the collection of communication lines and routers called?
write a program to print largest number of each row of a 2D array
What is malloc() function?
What is array of pointers to string?
What is this infamous null pointer, anyway?
What is ctrl c called?
What is switch in c?
What is function pointer c?
please give me some tips for the placement in the TCS.
What standard functions are available to manipulate strings?
What is a pointer variable in c language?