Implement a function that returns the 5th element from the
end in a singly linked list of integers in one pass.
Answer Posted / amol b
int return_fifth_from_end()
{
int a[5],curr_ct=0;
struct node *p;
p=head;
while(p->next!=NULL)
{
a[curr_ct%5]=p->val;
p=p->next;
curr_ct++;
}
if(curr_ct>=5)
return a[(curr_ct-5)%5];
else
return -1;
}
| Is This Answer Correct ? | 8 Yes | 0 No |
Post New Answer View All Answers
Why does the call char scanf work?
What is nested structure?
Can you write the function prototype, definition and mention the other requirements.
What is a good data structure to use for storing lines of text?
#define MAX(x,y) (x) >(y)?(x):(y) main() { inti=10,j=5,k=0; k= MAX(i++,++j); printf("%d..%d..%d",i,j,k); }
What is abstract data structure in c?
What is the correct code to have following output in c using nested for loop?
Explain #pragma statements.
Add Two Numbers Without Using the Addition Operator
Explain how do you search data in a data file using random access method?
Write a program to show the change in position of a cursor using c
In the DOS enveronment, normal RAM that resides beyond the 1mb mark. a) expanded memory b) swapped memory c) Extended memory d) none
Explain how are portions of a program disabled in demo versions?
Why is C language being considered a middle level language?
Explain modulus operator. What are the restrictions of a modulus operator?