struct node
{
int val;
struct node* next;
};
struct node* reverse (struct node* list)
{
/* initialization */
struct node *reversed_list_head = 0;
struct node *rest_orig_list = list;
/* build up the reversed_list like a stack while the original list
remains */
while ( rest_orig_list != 0 )
{
struct node *orig_list_tail = rest_orig_list->next;
/* the head of the remainder of the original list will be the
new head of the new list */
rest_orig_list->next = reversed_list_head;
reversed_list_head = rest_orig_list;
rest_orig_list = orig_list_tail;
}
return reversed_list_head;
}
Showing posts with label C plus plus. Show all posts
Showing posts with label C plus plus. Show all posts
Reverse Single Linked List
2007-02-27 | Posted by Rajesh Kumar Sitaraman at 6:17 AM 0 comments Links to this post
Tags: C plus plus , Technical
Interview Questions
I have compiled some of the interview questions related to MFC and COM
MFC Interview Questions
http://www.MegaShare.com/113993
COM Interview Questions
http://www.MegaShare.com/113996
2007-02-19 | Posted by Rajesh Kumar Sitaraman at 9:31 PM 0 comments Links to this post
Tags: .Net , C plus plus , Technical
Subscribe to:
Posts (Atom)
Loading...