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

With the help of using classes, write a program to add two numbers.

1044


What is #define?

1121


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

2026


What do you mean by dynamic memory allocation in c?

1105


What is the collection of communication lines and routers called?

1129


write a program to print largest number of each row of a 2D array

2327


What is malloc() function?

1170


What is array of pointers to string?

1095


What is this infamous null pointer, anyway?

1062


What is ctrl c called?

1053


What is switch in c?

1112


What is function pointer c?

1120


please give me some tips for the placement in the TCS.

2116


What standard functions are available to manipulate strings?

1156


What is a pointer variable in c language?

1111