4 ms·
Alternatively, you could recognize that your data structure doesn't suit your needs, and use a doubly-linked list.
by machrider 17y ago
Alternatively, you could recognize that your data structure doesn't suit your needs, and use a doubly-linked list.
- cperciva 17y agoThere are many situations where the cost of using a more sophisticated data structure outweighs the advantages of avoiding an occasional excessively slow operation.
- machrider 17y agoWe don't have enough information to know which situation this is. Hence, it's an "alternative" to consider.
- roundsquare 17y agoYou'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.