Click here to Skip to main content
12,632,234 members (26,059 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C
i want a proper code for this with the time complexity
Posted 16-Nov-12 2:20am
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

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Toggle a flag that tells if the list is traversed head-to-tail or tail-to-head.
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.
  Permalink  
v2
Comments
SafarTimura 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)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.161208.2 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100