Think of it as two lists linked together, rather than one doubly linked list, with one set of links being the first and the second the last. You can sort the second list with merge sort, which will be O (n log n). Now go through the list using the first link. For each node, check if there is (node.back)->key==node.key , and if you remove it from the list. Restore the back pointer during this crawl so that the list is correctly double-bound.
This is not necessarily the fastest method, but it does not use extra space.
Mark ransom
source share