Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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


Please Help Members By Posting Answers For Below Questions

What does %p mean?

1155


How will you write a code for accessing the length of an array without assigning it to another variable?

1094


What is hungarian notation? Is it worthwhile?

1272


What happens if header file is included twice?

1211


Explain what is the concatenation operator?

1230


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....

2044


Can we declare variables anywhere in c?

1053


How does sizeof know array size?

1170


Is flag a keyword in c?

1216


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.

2144


Explain threaded binary trees?

1211


write a c program to find the sum of five entered numbers using an array named number

2203


What are the 5 organizational structures?

1080


which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above

1784


What is the general form of function in c?

1071