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

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.

1933


Can you apply link and association interchangeably?

1070


What is the difference between Printf(..) and sprint(...) ?

1422


5 Write an Algorithm to find the maximum and minimum items in a set of ā€˜n’ element.

2035


What is the significance of c program algorithms?

1090


What kind of structure is a house?

990


how to execute a program using if else condition and the output should enter number and the number is odd only...

2203


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?

982


What is clrscr ()?

1051


Do pointers store the address of value or the actual value of a variable?

1018


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.

5398


Tell me can the size of an array be declared at runtime?

986


what is a constant pointer in C

1091


What is pass by reference in c?

1142


What is the benefit of using #define to declare a constant?

1042