dcsimg
Login | Register   
RSS Feed
Download our iPhone app
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   FORUMS  |   TIP BANK
Browse DevX
Sign up for e-mail newsletters from DevX

By submitting your information, you agree that devx.com may send you DevX offers via email, phone and text message, as well as email offers about other products and services that DevX believes may be of interest to you. DevX will process your information in accordance with the Quinstreet Privacy Policy.


Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: Beginner
Mar 13, 1998

WEBINAR:

On-Demand

Application Security Testing: An Integral Part of DevOps


C++ Linked list

Question:
How would you reverse a linked list? Have looked in books at school library, and in tutorial. Hope you can point me in the right direction. Thank you for your time.

Answer:
The only way to directly traverse a linked list in reverse is to have the links arranged this way. Normally, this involves a doubly linked list. While a simple linked list only contains a pointer to the next node, a doubly linked list contains both a pointer to the next node and to the previous node. A doubly linked list also requires a Tail pointer that points to the last node in the list. This way, you can traverse the list from either the start or the end. Although doubly linked lists require a little more work to insert and delete nodes, they are very common when that degree of flexibility is required.

DevX Pro
 
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

Sitemap
Thanks for your registration, follow us on our social networks to keep up-to-date