Click here to Skip to main content
11,495,945 members (63,272 online)
Rate this: bad
good
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 at 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 at 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
0 Dnyaneshwar@Pune 692
1 CHill60 318
2 Sascha Lefèvre 235
3 RyanDev 230
4 _Asif_ 155
0 Sergey Alexandrovich Kryukov 10,372
1 OriginalGriff 8,871
2 Sascha Lefèvre 3,899
3 Maciej Los 3,422
4 Richard Deeming 2,600


Advertise | Privacy | Mobile
Web02 | 2.8.150520.1 | Last Updated 16 Nov 2012
Copyright © CodeProject, 1999-2015
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