News for hackers. Stuff that matters.
Re:Nth-to-Last Element in a Singly Linked List by machrider on Sunday January 31, 2010 @05:47PM (#1091263)
Alternatively, you could recognize that your data structure doesn't suit your needs, and use a doubly-linked list.
Re:Nth-to-Last Element in a Singly Linked List by cperciva on Sunday January 31, 2010 @06:39PM (#1091333)
There are many situations where the cost of using a more sophisticated data structure outweighs the advantages of avoiding an occasional excessively slow operation.
Re:Nth-to-Last Element in a Singly Linked List by machrider on Sunday January 31, 2010 @07:58PM (#1091468)
We don't have enough information to know which situation this is. Hence, it's an "alternative" to consider.
Re:Nth-to-Last Element in a Singly Linked List by roundsquare on Monday February 01, 2010 @07:28AM (#1092231)
You're missing the point. With the question setup, you are supposed to assume that a doubly linked list is not possible, for whatever reason. Its meant to be an algorithm question, not a data structures question.