I got the code from wikipedia for linked list ( http://en.wikipedia.org/wiki/Linked_list ).
But it prints the result in reverse order (5 4 3 2 1 ). How to make this to print from beginning ( 1 2 3 4 5).
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Looking at the following example:
Elements are being added to the beginning of the linked list when you call
list_add. This is for efficiency reasons; you don’t have to transverse the entire linked list to insert an element (which you would have to do if you wanted to append).To print in reverse, you can use recursion, build your own stack (which is the blind man’s recursion), or recreate the list in reverse. A recursive version: