educative.io

Need at least two pointers to maintain order

In a sorted set, we can assume that we need at least two pointers to maintain order among elements — one pointer to the previous element and one to the next element.

why do we need two pointers to maintain order among elements?

Hey @Dewey_Munoz

We use two pointers for better optimization so that we can go back and forward at every node, which helps in reducing time complexity.

Shahereyaar Kamal | Technical Content Engineer