New answers tagged


Copy the list into an array, sort the array, construct a linked list from it. Done. It suffices to populate the array with pointers (references) to the values; you don't need to copy the values themselves. The running time will be $\Theta(n \log n)$ if you use an appropriate sorting algorithm -- much faster than quadratic time.


If you mean the next pointer of the node that was deleted, as far as I know it is normally not necessary to set the pointer to null. Once the node is deleted, if the code is not buggy, then the code should not access the node after it is deleted, so the value of its next pointer should be irrelevant. Sometimes some people do set the pointer to null, as a ...

Top 50 recent answers are included