//
you're reading...
C++, Data Structures, Source Code

B2B::DisplayListReverse

I am starting a series of posts that are targeted towards Data Structures that I had been wanting to write for a long time. They are simple code snippets. For many this might not be useful but for some, it might be. So here we go, the first one is to print the contents of a Linked list in reverse order

void displayReverse(node* head){
	if(head==NULL){
		cout<<"Nothing to display"<<endl;
	}
	else
	{
		if(head->next != NULL){
			displayReverse(head->next);
		}
		else
		{
			cout<<head->data<<endl;
			return;
		}
		cout<<head->data<<endl;
	}
}
Advertisements

Discussion

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: