Click here to Skip to main content
15,877,966 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
i want a proper code for this with the time complexity
Posted
Comments
OriginalGriff 16-Nov-12 7:37am    
This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind.
Use the "Improve question" widget to edit your question and provide better information.

Plus, demanding code is a very good way to annoy people, and to get nothing at all...

1 solution

Toggle a flag that tells if the list is traversed head-to-tail or tail-to-head.
C++
HeadToTail= !HeadToTail;

This is O(1).

Don't forget to modify the list traversal routine to take this flag into account.

No kidding, this IS an acceptable solution.
 
Share this answer
 
v2
Comments
Guyverthree 20-Nov-12 10:50am    
Yeah i agree no reversing is required for a doubly linked list.

:)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900